【发布时间】:2015-05-18 11:08:35
【问题描述】:
我想创建对话框以确认提交按钮。所以我正在使用角度用户界面引导程序。
这是我的主控制器代码:
FrontEnd.controller('PostViewController',function($scope,$stateParams,PostFactory, $modal){
$scope.openConfirm = function(size) {
var modalInstance = $modal.open({
animation: true,
templateUrl: 'ConfirmDialog.html',
controller: 'ConfirmDialogController',
size: size,
resolve: {
form: function () {
return $scope.form;
},
//tried with this line as well, but could not resolve error
PostFactory: "PostFactory"
}
});
modalInstance.result.then(function (response) {
$scope.isSurveySubmitted = true;
$scope.message = response.message;
//$scope.selected = selectedItem;
}, function () {
console.log('Modal dismissed at: ');
});
};
});
这是我的 ConfirmDialogController:
FrontEnd.controller('ConfirmDialogController', function($scope, $http, $modalInstance, form, PostFactory){
$scope.ok = function () {
PostFactory.SubmitSurvey(form).success(function(response){
$modalInstance.close(response);
}).success(function(response){
$modalInstance.close(response);
});
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
});
Modal 正确打开,没有错误。当我单击取消按钮时,它会按预期关闭模式。但是当我点击 Ok 时,它会调用 $scope.ok() 但在控制台中抛出错误并显示 PostFactory is undefined 消息。
那该怎么办?感谢您的帮助。
【问题讨论】:
-
那么 PostFactory 的代码在哪里???错误很清楚,切中要害
标签: angularjs angular-ui-bootstrap