import { Component, OnInit } from '@angular/core';
import { MSOService } from '../../services/mso.services';
import { Subject } from 'rxjs/Subject';
import { ActivatedRoute, Router } from '@angular/router';
@Component({
selector: 'app-objetos',
templateUrl: './objetos.component.html',
styleUrls: []
})
export class ObjetosComponent implements OnInit {
objetos:any [] = [];
titles:any [] = [];
url_activo:object ;
dtOptions: any = {};
dtTrigger: Subject<any> = new Subject();
constructor(public activatedRoute: ActivatedRoute,
public _msoService: MSOService,
public router: Router) {
public router: Router) {
this.activatedRoute.params
.subscribe( params => {
this.url_activo = params;
}); this.url_activo = params;
}
ngOnInit(): void {
this.dtOptions = });{
pagingType: 'full_numbers',
}
ngOnInit()pageLength: void{
10,
this.dtOptions = {
pagingType: 'full_numbers',
pageLength: 10,
dom: 'Bfrtip',
scrollx: true,
scrolly: true,
buttons: [
{
extend: 'colvis',
collectionLayout: 'fixed two-column',
postfixButtons: [ 'colvisRestore' ]
},
'copy',
'print',
'excel',
'csv',
'pdf',
{
text: 'Add ',
key: '1',
action: function (e, dt, node, config) {
this.router.navigate(['nuevo']); //aqui es donde esta el error, this router no definida.
this.router.navigate(['nuevo']);
}
}
],
columnDefs: [
{
targets: [0,1],
visible: false
}
]
};
this.activatedRoute.params
.subscribe( params => {
this._msoService.getObjetos( params['APPNAME'], params['MODELNAME'])
.subscribe(objetos => {
this.objetos = objetos;
this.titles = Object.keys(objetos[0]);
this.dtTrigger.next(objetos);
});
});
}
}
}
}