Reputation: 5083
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
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