我使用 angular ng-view 的 native 指令开发 SPA 来更改 View ,问题是其中一个 View 有一个我写的自定义指令,当加载路由时,该指令不起作用。
这是应用程序的配置方法和未启动的自定义指令: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>
.
关于javascript - ng-view 中的嵌套指令在 AngularJs 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19390425/