Jue*_*tat 6 javascript angularjs angularjs-directive angular-template
错误:[$ compile:multidir]要求模板的多个指令[statbox,statbox]:
(在控制台上)
在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>
Run Code Online (Sandbox Code Playgroud)
在dashboard.module.js里面
var dashboardModule = angular.module('dashboard', ['ngRoute']);
Run Code Online (Sandbox Code Playgroud)
在dashboard.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...
}]
});
Run Code Online (Sandbox Code Playgroud)
在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 ...
}]
});
Run Code Online (Sandbox Code Playgroud)
在app.js里面
var app = angular.module('buttonMasher', ['ngRoute', 'dashboard', ...]);
Run Code Online (Sandbox Code Playgroud)
在dashboard.template.html里面
... stuff ...
<div id="history">
... stuff ...
<p><b>Statbox</b></p>
<statbox></statbox>
</div>
Run Code Online (Sandbox Code Playgroud)
在statbox.template.html里面
<div id="statbox">
<p>{{$ctrl.statboxText}}</p>
Run Code Online (Sandbox Code Playgroud)
我做错了什么,为什么我会得到这个多指令错误?
每当我<script src="js/dashboard/statbox.component.js"></script>
从index.html 注释掉一切都有效但statbox控制器没有加载.
(完整项目在这里:Github:carloworks/masher - 一个人可以克隆并运行弹簧,启用配置文件"dev".)
错误:[$ compile:multidir]要求输入模板的多个指令[statbox,statbox]
当您.js在index.html中包含两次并且绑定指令时编译器不知道要选择哪个模板时,很可能会发生此错误.
你应该检查:
.component('statbox',{}) | 归档时间: |
|
| 查看次数: |
2363 次 |
| 最近记录: |