Reputation: 1317
I'm trying to add a component instead of a directive but it doesn't work. my directive:
(function() {
'use strict';
angular.
module('eventeditor')
.directive("displayTab",
function() {
return({
templateUrl: function(elem, attr){
if(attr.tabname === 'details') return "/organizer/fragments/detailsform.html";
}
});
}
);
})();
Component style:
(function() {
'use strict';
angular.
module('eventeditor')
.component("displayTab", {
templateUrl: function($element, $attrs) {
if ($attrs.tabname === 'details') return "/organizer/fragments/detailsform.html";
}
});
})();
What am I doing wrong? I use my template like:
<div ng-switch="nav.getTab()">
<div ng-switch-when="details" display-tab="" tabname="details">details</div>
</div>
Upvotes: 0
Views: 568
Reputation: 4777
Components work only on element names while directives default to element names and attribute names.
<div ng-switch="nav.getTab()">
<display-tab ng-switch-when="details" tabname="details">details</display-tab>
</div>
Upvotes: 1