Guest User

Untitled

a guest
Jan 17th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2.  
  3. @Component({
  4. selector: 'ngx-cadastro',
  5. template: `
  6. <div class="container btns-listagem">
  7. <div class="row campoPesquisa">
  8. <div class="col-xs-12 col-sm-6 div-btnPesquisa">
  9. <div class="input-group">
  10. <input type="text" class="form-control" placeholder="Pesquisar" name="pesquisar" [(ngModel)]="pesquisar">
  11. <span class="input-group-btn">
  12. <button class="btn btn-secondary" id="btn-prequisa" type="button" data-toggle="tooltip" data-placement="top" title="Pesquisar">
  13. <i _ngcontent-c30="" class="ion-search"></i>
  14. </button>
  15. </span>
  16. </div>
  17. </div>
  18. <div class="col-xs-12 col-sm-6 btns-funil-novo">
  19. <span class="input-group-btn">
  20. <button type="button" class="btn btn-info" id="btn-funil" data-toggle="tooltip" data-placement="top" title="Filtro">
  21. <i _ngcontent-c30="" class="ion-funnel"></i>
  22. </button>
  23. <button (click)="novoCadastro()" type="button" class="btn btn-success border-right-0" data-toggle="tooltip" data-placement="top" title="Novo" id="btn-novo">
  24. <i _ngcontent-c30="" class="ion-plus-round"></i>
  25. </button>
  26. </span>
  27. </div>
  28. </div>
  29. </div>
  30. <router-outlet></router-outlet>`,
  31. })
  32.  
  33. export class CadastroComponent {}
  34.  
  35. import { Component, OnInit } from '@angular/core';
  36.  
  37. import { CidadeService } from './cidade.service';
  38. import { CadastroComponent } from '../cadastro.component';
  39.  
  40. @Component({
  41. selector: 'ngx-lista-cidades',
  42. templateUrl: './cidade.component.html',
  43. providers: [ CidadeService ],
  44. })
  45.  
  46. export class ListaCidadesComponent extends CadastroComponent implements OnInit {
  47.  
  48. private cidades: object[];
  49. private coluna: string;
  50.  
  51. constructor(private cidadeService: CidadeService) {
  52. super();
  53. }
  54.  
  55.  
  56. ngOnInit() {
  57. this.ListaTodasCidades();
  58. }
  59.  
  60. novoCadastro() {
  61. console.log('aqui');
  62. }
  63.  
  64. private ListaTodasCidades() {
  65.  
  66. this.cidadeService.TodasCidades().then((response: object[]) => {
  67. this.cidades = response.sort(function(a: any, b: any) {
  68. return a.NOME < b.NOME ? -1 : a.NOME > b.NOME ? 1 : 0;
  69. });
  70. }, (error) => {
  71. console.log(error);
  72. });
  73. }
  74.  
  75. private ordena(coluna) {
  76.  
  77. if (this.coluna === coluna) {
  78. this.cidades.reverse();
  79. } else {
  80. this.cidades.sort((a, b) => {
  81. return a[coluna] < b[coluna] ? -1 : a[coluna] > b[coluna] ? 1 : 0;
  82. });
  83. }
  84. this.coluna = coluna;
  85. }
  86. }
Add Comment
Please, Sign In to add comment