Angular 2 (push) and jQuery.clone () not working

So, I have a template for Angular 2, and this template uses jQuery components that "work". Well .. When the page changes, this fire executes a jQuery function that refines the sidebar, adding all the top nav bar elements using jQuery's "clone ()" method. Something like that:

... code ommited ...
 $navbar = $('nav').find('.navbar-collapse').first().clone(true);
... more code ommited...

      

This works well, it clones all the navbar items in the sidebar. The only problem is the button I have in the sidebar to log out. This is the code:

<a class="text-danger link-pointer" (click)="doLogout()">
    <i class="pe-7s-power"></i> Cerrar Sesión
</a>  

      

As you can see, I am using a (click) binding which calls a method of my class. The problem is this: When the jQuery clone clone is then cloned but no binding . Thus, the connection is broken. I cannot use the [routerlink] binding because I need to execute some code before redirecting the user to the logout page.

Any idea to do this? Many thanks.

+3


source to share





All Articles