我尝试在自定义指令中使用 ng-view
但它不起作用,而且也没有给我任何控制台错误。
这是我的指令:
(function() {
'use strict';
angular
.module('app')
.directive('header', Header);
Header.$inject = ['USER_AGENT'];
function Header(USER_AGENT) {
return {
restrict: 'A',
templateUrl: 'app/shared/header/header.html',
controller: controller
}
function controller($scope) {
$scope.isMobile = USER_AGENT.isMobile;
}
}
})();
在 header.html
文件内,我调用了 ng-view
就像我在外部调用它一样(当它工作时)。
是否可以将 ngView
嵌套在自定义指令中?
最佳答案
AngularJS 不支持在一个应用程序中使用多个 ng-view
。如果你想要它 - 你必须使用另一个路由引擎,例如 Angular UI 的 ui-router
关于javascript - AngularJS:自定义指令内的 ngView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29537805/