Kullanmak istediğin template'i Component'e paramatere olarak geçebilirsin. Şöyleki:
module.component('testComponent', {
controllerAs: 'vm',
controller: Controller,
bindings: {
template : '@'
},
templateUrl: function($element, $attrs) {
var templates = {
'first' :'components/first-template.html',
'second':'components/second-template.html',
'third' :'components/third-template.html'
}
return templates[$attrs.template];
}
});
Component tanımlamandan sonra istediğin template'i aşağıdaki gibi kullanabilirsin.
<test-component template='first'></test-component>