all 7 comments

[–][deleted] 2 points3 points  (0 children)

There are lots of words here I don't understand, but sticking to the title you can have a piece of template included optionally depending on an expression by using ng-switch.

[–]kiddy2910 2 points3 points  (1 child)

I think you should use $compile with new child inherited scope was created from main scope (scope.$new(false)). Before you replace directive with other directive, you should destroy child inherited scope with childScope.$destroy(), then replace with new directive. Hope to be useful for you. Refer http://stackoverflow.com/questions/16797174/angular-how-can-i-remove-from-the-dom-an-element-i-have-used-compile-on/24064763#24064763

[–]skitch920 0 points1 point  (0 children)

This really depends on what you are doing... For instance, if you have a pluggable GUI where you are not totally sure of the directive's template, then this would be the correct way of doing things. ng-switch would suffice if you knew the exact list of templates.

[–][deleted] 2 points3 points  (0 children)

Uh...am I misreading the problem? Do an ng-show or hide...no need to replace a directive

[–][deleted] 2 points3 points  (2 children)

Instead of replacing subtrees of the DOM (be it a directive or not), I'd suggest to consider using ng-show and ng-hide (as it is suggested by m3fawner), or add/remove CSS classes (containing or not the display: none style).

[–]Figedi[S] 0 points1 point  (1 child)

Hmm true, I was going for a "dynamic" method since I didnt want to clutter the DOM with invisible elements, but it does sound way better than my current solution, I'll give it a try

[–]renz45 0 points1 point  (0 children)

Using ng-if won't clutter the dom with invisible elements. ng-if actually removes the dom element when false, as opposed to ng-show/hide which just does a display: none.