[英]Nested directive within ng-view doesn't work AngularJs
我使用角度ng-view中的native指令開發SPA以更改視圖,問題是其中一個視圖有一個我寫過的自定義指令,當加載路徑時,指令不起作用。
這是App的配置方法和不啟動的自定義指令:S
climbingApp.config(
function( $routeProvider ){
$routeProvider.
when('/', {
controller: 'AppCtrl'
}).
when('/newSector', {
template: '<formNewSector></formNewSector>',
controller: 'addSector',
}).
otherwise({ redirectTo: '/'});
}
);
climbingApp.directives
.directive(
'formNewSector',
function() {
return {
restrict: 'E',
template: "<div>gato</div>",
replace: true,
link: function( scope, iElement, iAttrs ){
}
}
});
您在template
為指令拼錯了標記。 對於名為formNewSector
指令,它應該是<form-new-sector>
,而不是<formNewSector>
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.