Error: [$compile:multidir] Multiple directives [statbox, statbox] asking for template on:多個指令要求的模板上
(在控制檯)
內的index.html
<script src="js/dashboard/dashboard.module.js"></script>
<script src="js/dashboard/dashboard.component.js"></script>
<script src="js/dashboard/statbox.component.js"></script>
內dashboard.module.js
var dashboardModule = angular.module('dashboard', ['ngRoute']);
內DA shboard.component.js
angular.module('dashboard').component('dashboard', {
templateUrl: 'templates/dashboard/dashboard.template.html',
controller: ['$scope', '$routeParams', '$http', '$rootScope', '$log', function DashboardController($scope, $routeParams, $http, $rootScope, $log) {
...stuff NOT REFERENCING STATBOX by any means...
}]
});
內statbox.component.js
angular.module('dashboard').component('statbox', {
templateUrl: 'templates/dashboard/statbox.template.html',
controller: ['$http', '$rootScope', '$log', function StatboxController($http, $rootScope, $log) {
... some random get request ...
}]
});
而且裏面app.js
var app = angular.module('buttonMasher', ['ngRoute', 'dashboard', ...]);
內dashboard.template.html
... stuff ...
<div id="history">
... stuff ...
<p><b>Statbox</b></p>
<statbox></statbox>
</div>
內statbox.template.html
<div id="statbox">
<p>{{$ctrl.statboxText}}</p>
什麼我做錯了,爲什麼會這樣多指令錯誤?
每當我從index.html註釋掉<script src="js/dashboard/statbox.component.js"></script>
一切正常,但statbox控制器沒有加載。
(全項目是在這裏:Github: carloworks/masher - 一個可以克隆並運行配置文件「開發」啓用的春天。)
請添加HTML代碼中調用這兩個組件 – Karim
@Karim編輯,對不起我的壞 –