【发布时间】:2016-05-26 02:15:24
【问题描述】:
我正在尝试添加组件而不是指令,但它不起作用。 我的指令:
(function() {
'use strict';
angular.
module('eventeditor')
.directive("displayTab",
function() {
return({
templateUrl: function(elem, attr){
if(attr.tabname === 'details') return "/organizer/fragments/detailsform.html";
}
});
}
);
})();
组件样式:
(function() {
'use strict';
angular.
module('eventeditor')
.component("displayTab", {
templateUrl: function($element, $attrs) {
if ($attrs.tabname === 'details') return "/organizer/fragments/detailsform.html";
}
});
})();
我做错了什么? 我使用我的模板:
<div ng-switch="nav.getTab()">
<div ng-switch-when="details" display-tab="" tabname="details">details</div>
</div>
【问题讨论】:
-
您在浏览器控制台上看到任何错误吗?您如何在模板中使用指令/组件?
-
@ShuheiKagawa 没有任何错误。现在我添加我如何使用我的模板
标签: javascript angularjs components directive