2
我有一个配置,如下plunkr:http://plnkr.co/nya3cr如何在UI视图中显示自定义指令?
中,我有作为的状态:
.state('main.layout', {
url : '/l',
abstract : true,
views : {
'left' : {
templateUrl : 'left.html',
controller : 'LeftCtrl'
},
'right' : {
templateUrl : 'right.html',
controller : 'RightCtrl'
},
'middle' : {
templateUrl : 'middle.html',
controller : 'MiddleCtrl'
},
'bottom' : {
templateUrl : 'bottom.html'
}
}
})
我想使用这样的UI的视图定制指令。
.directive('sidebarDirective', function() {
return {
template: 'Hello hello!',
restrict: 'E',
link: function postLink(scope, element, attrs) {
element.text('this is the sidebarDirective directive');
}
};
});
,但我不能一个用户界面视图元素中使用它,比如在我的配置,我试图让我的自定义指令(侧边栏指令)在left.html
<div sidebar-directive></div>
以及如在right.html中,但它不显示。我可能会忽略关于如何在UI视图状态中包含指令的一些关键理解。请帮忙。
非常感谢您匹配!假设如果我必须控制指令显示时的逻辑,我应该在哪里写这个逻辑? – 2014-11-24 07:48:00
我会这样说:由您创建的指令,用于您的应用程序 - 适合您。所以完全取决于你的需求。没有一般规则。上下文应该决定。我会说;)希望它有一点帮助;)与'UI-Router'好运,真棒工具... – 2014-11-24 07:50:12