gpt4 book ai didi

angularjs - 未知提供程序 : $modalInstanceProvider <- $modalInstance

转载 作者:行者123 更新时间:2023-12-04 16:24:14 24 4
gpt4 key购买 nike

我正在尝试像这样使用 angularui-bootstrap 调用模态。

var authApp = angular.module('AuthApp', ['ui.bootstrap']);
authApp.controller('AuthController',
['$scope', '$uibModal',
function ($scope, $uibModal) {
//$scope.credentials = {
// userName: "",
// uPassword: "",
// rememberMe: ""
//};
$scope.OpenLoginModal = function (templateUrl) {
var modalInstance = $uibModal.open({
animation: false,
backdrop: 'static',
templateUrl: templateUrl,
controller: 'loginModalController'//,
//resolve: {
// credentials: function () {
// return $scope.credentials;
// }
//}
});
};
}]);

authApp.controller('loginModalController',
['$scope', '$modalInstance', 'AuthService',
function ($scope, $modalInstance, AuthService) {
//$scope.credentials = credentials;
//$scope.headerTitle = 'Login Information';

$scope.LoginUser = function () {
//var data = {};
//console.log($scope.credentials);
AuthService.ValidateServerAccessDetails(data).then(function (response) {
//$modalInstance.close(response.data);
}, function (response) {
//$scope.userName = "";
//$scope.passWord = "";
});
};

$scope.CancelLogin = function () {
$modalInstance.dismiss('cancel');
};
}]);

我收到这个错误,

Error: [$injector:unpr] Unknown provider: $modalInstanceProvider <- $modalInstance <- loginModalController



我在 Plunker 中也遇到了同样的错误: https://plnkr.co/edit/3rmapgrLhYJ3plyPWm87

我究竟做错了什么?
使用的版本是 angularjs-1.4.7 和 angularui-1.1.2

P.S:我在这里检查了很多答案。接近的问题之一是这个问题。 Unknown provider: $modalInstanceProvider <- $modalInstance in Angularjs modal

最佳答案

尝试将依赖项更改为 $uibModalInstancedocumentation 中的示例所用.你的 Controller 看起来像:

authApp.controller('loginModalController', [
'$scope', '$uibModalInstance', 'AuthService',
function ($scope, $uibModalInstance, AuthService) {
// implementation
}

关于angularjs - 未知提供程序 : $modalInstanceProvider <- $modalInstance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35195890/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com