Dynamically changing templateURL in Directives

10,114 views
Skip to first unread message

Abdul Azeez Shaik

unread,
Oct 7, 2012, 11:11:27 AM10/7/12
to ang...@googlegroups.com
Hi,

Is it possible to dynamically change(based on the attributes passed) the templateURL of the directive?
Other way of achieving the same objective is using ui-if or no-show/hide in the same template. I am trying to find out if there is a better of way doing this, like having two different templates and changing templateURL dynamically.

Kindly let me know if this can be done.

Thanks,
Abdul

Andy Joslin

unread,
Oct 7, 2012, 12:34:04 PM10/7/12
to ang...@googlegroups.com
Don't use templateUrl, and use ng-include inside a template instead?

instead of:
 templateUrl: 'hello.html'

do:
 template: '<div ng-include="curTemplate"></div>'

Eddie Huang

unread,
Oct 8, 2012, 6:11:55 PM10/8/12
to ang...@googlegroups.com

Eddie Huang

unread,
Oct 8, 2012, 6:14:15 PM10/8/12
to ang...@googlegroups.com
This question is so timely, the answer is no. The issue below is 4 months old now.

( I was trying to add different pager directives, which dynamic template url would be super helpful... In the end, I made the existing pager configurable...)

Carsten Kraus

unread,
Oct 9, 2012, 4:42:47 AM10/9/12
to ang...@googlegroups.com
I also had a need for this, and finally went with the ng-include workaround.

Maybe you +1 it, too?
Reply all
Reply to author
Forward
Message has been deleted
0 new messages