Amitava
Amitava

Reputation: 5083

Angularjs directive ng-click not triggering

Here is my plnkr http://plnkr.co/edit/U5WiZzhX31ifux33enYh

I'm writing a in-place editor directive. It works as expected first time but subsequent times Save or Cancel buttons does not work. Why is that?

In plnkr when I click Save or Cancel 2nd time, it does nothing but in my local dev environment it reloads page.

I'm angular newbie, appreciate your help. Thanks!

Upvotes: 0

Views: 1747

Answers (1)

bmleite
bmleite

Reputation: 26880

If you remove the editor element from the DOM you will have to recompile the template before adding it again, or otherwise you will loose access to the scope.

Change your show function to something like this:

function show(){        
    editor = $compile(template)(scope);
    element.after(editor);
    element.hide();
}

Upvotes: 4

Related Questions