FlyingTurtle
FlyingTurtle

Reputation: 155

Using angular function into ElementRef/native element

how to access angular function using elementRef.

ngAfterViewInit() {

    let _self = this;
       this.datatable.on('m-datatable--on-layout-updated', function(e){

          $(_self.elRef.nativeElement).find('.deleteFn').click(function(){
          this.router.navigate(['agency/setup']);//like this if using angular

       });
    });
}

i want to access the router like above. is it possible? or any workaround?

Upvotes: 0

Views: 1055

Answers (1)

Jai
Jai

Reputation: 74738

Try changing this:

.click(function(){

to the fat arrow syntax:

.click(() => {

ngAfterViewInit() {

    let _self = this;
       this.datatable.on('m-datatable--on-layout-updated', (e) =>{

          $(_self.elRef.nativeElement).find('.deleteFn').click(() => {
          this.router.navigate(['agency/setup']);//like this if using angular

       });
    });
}

Or you might add this as:

_self.router.navigate(....);

Upvotes: 1

Related Questions