所以我已经关注这个问题太久了。真的希望有人能帮助我:) 我只是想创建一个模块,为 AngularJS 中的站点标题创建指令和 Controller 。我没有收到任何错误,代码中的日志也不会显示。这是与 header 模块相关的代码:
header/header.js
'use strict';
angular.module('myApp.header', [])
.directive("headerBar", [function(){
return {
restric: "E",
templateUrl: "header/header.html",
controller: 'HeaderCtrl'
};
}])
.controller('HeaderCtrl', ['$log', function($log) {
$log.log('test header controller');
}]);
app.js
angular.module('myApp', [
'ngRoute',
'myApp.header'
]).
config(['$routeProvider', function($routeProvider) {
$routeProvider.otherwise({redirectTo: '/'});
}]);
index.html
<script src="header/header.js"></script>
<header-bar></header-bar>
最佳答案
我发现您的指令定义中有一个拼写错误:
- 应该是
restrict: "E"
,您目前缺少“t”
关于javascript - AngularJS 模块不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29697165/