AngularjS美元注入器:unpr
AngularjS $injector:unpr
我有以下控制器:
/** Calculation controller **/
app.controller('calculationController', ['$scope','$modal','content', function($scope, $modal, content) {
/** data recieved from get request **/
$scope.data = content.data; //promise
/** function to edit data **/
$scope.edit = function(item){
var htmlContents = {
title: 'Edit product',
body: 'Please confirm that you want to edit the product'
}
var modalInstance = $modal.open({
templateUrl : templateBase + 'views/modal/dialog.html',
controller : 'modalInstanceController',
resolve : {
items : function() { return item; },
html : function() { return htmlContents; }
}
});
}
/** function to delete data **/
$scope.trash = function(item){
}
}]);
app.controller('modalInstanceController', ['$scope', '$modalInstance','items','html', function($scope,$modalInstance,items,html) {
$scope.title = html.title;
$scope.body = html.body;
}]);
我想要完成的是打开一个对话框的内容从'dialog.html'但是一旦我点击:
<img ng-src="images/icn_edit.png" ng-click="edit(item)" alt="Edit">
$injector:unpr出现在控制台日志中
dialog.html的内容如下:
<div ng-controller="modalInstanceController">
<div class="modal-header">
<h3>{{title}}</h3>
</div>
<div class="modal-body">
{{body}}
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">OK</button>
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
我知道我错过了注入的东西,但经过几个小时的查看代码,我无法找到什么…
从我可以观察到'$scope', '$modalInstance','items','html'被注入到modelInstanceController..
感谢您的帮助。
谢谢
从你的dialog.html中删除
Ng-controller="modalInstanceController"
应该是普通的div,这样就可以了
dialog.html的html标记应该像这样:
<div>
<div class="modal-header">
<h3>{{title}}</h3>
</div>
<div class="modal-body">
{{body}}
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">OK</button>
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
相关文章:
- AngularJS 服务注入器错误
- 在运行时从Angular注入器检索实例
- 最小化httpInterceptor AngularJS$注入器错误
- AngularJS:骨架应用程序上的注入器模块rr错误
- 通过注入器获取url参数查询
- 如何修复角度缩小生成后的注入器错误
- 如何使用TypeScript静态注入器模式注入“$rootScope”
- 注入器使用什么逻辑来决定传递给控制器的作用域?
- 在指令中手动从注入器获取依赖
- Angularjs,Karma控制器单元测试注入器:modulerr
- AngularJs注入器模块错误
- 为什么我不能把服务注入到Angular的工厂/注入器中?
- 角注入器错误帮助>
- 注入器已创建.无法注册模块
- Angular注入器自调用函数语法错误
- AngularjS美元注入器:unpr
- 尝试使用角网格化时,Angular注入器出错
- Angular无法在IE9上工作,可能是由于内部注入器
- 角.注入器不像想象的那样工作
- Angular 2和ngmodule注入器