所以我一直在尋找這個太長時間。真的希望有人能幫助我:)我只是想創建一個模塊,在AngularJS中爲我的網站標題創建一個指令和控制器。我沒有得到任何錯誤,我的代碼中的日誌不會顯示。這是涉及到所述端接頭模塊的代碼:AngularJS模塊不工作
頁眉/ 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>
你初始化了應用程序嗎? – avcajaraville
爲什麼我要添加一個對象相關的指令到我的主模塊?是的,我初始化應用程序,路由模塊完美工作。 –