*tl;dr In simple cases use ng-if shown above, in advanced cases you can see 
my solution below*
Thanks for the response. On this project and my last, I have had plenty of 
cases of ng-if statements so i'm pretty familiar with them but it wasn't 
the right path for this project.
In my example above I only showed the locked part of the button, my buttons 
have to do all sorts of things so I decided to go the custom directive 
route instead of 
having nested ng-if statements about 6 levels deep like I have now. Being 
able to just pop a custom button element into my templates is much more 
handy.

My solution:

http://plnkr.co/edit/SNkiyyPy6gnT4UbgWwny?p=preview

The trick was compiling outside the dom, then adding it to the dom:

if (isLocked === "false" || isLocked === false)
{
    elem.css('background-color','green');
   
    var newChild = '<div ui-sref></div>';
   
    var newCompile = $compile(newChild,scope);
   
    elem.children().replaceWith(newCompile(scope));
}


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to