Angular.ui - 将数据传递到模态时出错
Angular.ui - Error passing data to modal
我创建了一个模式来编辑列表中的对象。以下是列表:
<div class="container">
<label class="text-center">Previous Grades</label>
<table class="table">
<th ng-repeat="head in tableHeadings"> {{head}}</th>
<tr ng-repeat="gr in grades track by $index" >
<td > {{gr.name}}</td>
<td>{{gr.teacher}}</td>
<td> {{gr.score}}</td>
<td><button class="btn btn-info btn-sm" ng-click="open($index)"><span class="glyphicon glyphicon-pencil"></span></button></td>
</tr>
</table>
</div>
这是打开模态的函数:
$scope.open = function (index) {
var modalInstance = $modal.open({
templateUrl: '../views/modalEdit.html',
controller: 'modalInstanceController',
resolve: {
items: function () {
return $scope.grades;
},
index: function (){
return index;
}
}
})
这是模态控制器:
.controller('modalInstanceController', function ($scope, $modalInstance, grades, index) {
$scope.grades = grades;
$scope.index = index;
$scope.gradeEditing = $scope.grades[index];
$scope.ok = function(){
$modalInstance.close();
};
$scope.cancel = function(){
$modalInstance.dismiss('cancel');
}
});
我收到一个$injector错误!我注入了解析值,但它仍然不起作用:/这就是我得到的错误:
> Error: [$injector:unpr] Unknown provider: gradesProvider <- grades
http://errors.angularjs.org/1.3.4/$injector/unpr?p0=gradesProvider%20%3C-%20grades
有什么想法吗?
这是因为您在解析中将"等级"定义为"项目",而不是成绩:
resolve: {
items: function () {
return $scope.grades;
},
index: function (){
return index;
}
}
使其如下所示,它将起作用:
resolve: {
grades: function () {
return $scope.grades;
},
index: function (){
return index;
}
}
相关文章:
- 我想使用模态通过php文件发送邮件,并且我希望在提交关闭后关闭pop
- 打开一个模态并将其链接到AngularJS中的指令
- SemanticUI模态not onDeny/onApprove事件未激发
- 有没有比在app.js上绑定模块名称更好的方法来动态加载视图模型和视图以显示模态
- 如何通过所选索引(AngularJS)在模态弹出窗口中显示数据
- 包含数据库中相关信息的开放模态
- bootstrap消除模态并显示另一个模态
- 模态提示-如何重写此代码
- 模态框无法正常工作
- 将数据传递给由服务创建的Ionic模态
- iframe模态无法关闭
- 点击AngularJS模态窗口捕捉背景事件
- jqueryajax调用是复制url,当在模态视图之后在外部js文件中进行调用时
- 使用模态对话框(JQuery)编辑函数
- 如何在模态实例中使用filter
- 页面上有多个模态框
- 如果满足某些条件,如何在不调用模态的情况下首先调用类
- Angular.ui - 将数据传递到模态时出错
- 尝试用ruby在模态中打开pin图像onclick时出错
- 打开模态时angular js指令出错