angularjs - How do I use different template urls for same component in angular 1.5 -


i've implemented component in following way

angular.module('modulename')         .component('mycomponent', {             templateurl: 'templatepath1.tpl.html',             controller: mycontroller,             controlleras: 'vm',             bindings: {                 b1: '&',                 b2: '&'             }         }); 

i'm using <my-component b1="something1" b2="something2"></my-component>

now, want use same mycontroller template residing @ templatepath2.tpl.html.

one way create component mycomponent2,

angular.module('modulename')         .component('mycomponent2', {             templateurl: 'templatepath2.tpl.html',             controller: mycontroller,             controlleras: 'vm',             bindings: {                 b1: '&',                 b2: '&'             }         }); 

is there way can use previous component , select templateurl based on attr? if yes, how should 1 that?

templateurl can function, gets element , attributes arguments:

angular.module('modulename')     .component('mycomponent', {         templateurl: function(element, attrs) {                       return 'templatepath' + attrs.x + '.tpl.html';                      },  <my-component x="1"></my-component> 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -