我有一个模态和做一些过程来更新一个值从模态,它不是从我的控制器更新。请让我知道如何获得值($scope.currentItem.value)从模态回控制器。
$scope.showModalForm = function(data, index) {
$scope.currentItem = data;
ngDialog.open(
{
template: '/scripts/app/panel/MyInfo.html',
controller: 'MyInfoController',
scope: $scope,
width:"50%",
})
};
angular.module('app')
.controller('MyInfoController', function ($scope,$http, $log) {
$scope.submit = function() {
// OPen modal and process sucessfully need to send the approve back to controller
if(process) {
$scope.currentItem.value = "Corrected";
}
if(!process) {
$scope.currentItem.value = "Wrong";
}
}
}
根据ngDialog文档:
Scope对象,该对象将传递给对话框。如果您使用具有单独$scope服务的控制器,则该对象将被传递给$scope。美元父参数
所以,在MyInfoController中你需要引用父控制器的$scope作为$scope。$parent而不是$scope。这样的:
$scope.$parent.currentItem.value = "Corrected";
这是一个工作的plunk