问题描述
我使用的是工作的罚款,但是当我尝试使用关闭它modalInstance它给上面error.Here是我的code角引导UI模式
I am using angular bootstrap ui modal which is working fine but when I try to close it using modalInstance it gives above error.Here is my code
var app = angular.module('LoginModule', ['ui.bootstrap']);
app.controller('LoginModal', ['$scope', '$modal', function ($scope, $modal) {
$scope.animationsEnabled = true;
$scope.open = function (size) {
var modalInstance = $modal.open({
animation: $scope.animationsEnabled,
templateUrl: '/app/template/Login.html',
controller: 'LoginController',
size: size
});
}
}]);
app.controller('LoginController', ['$scope', '$modalInstance', '$http', function ($scope, $modalInstance, $http) {
$scope.model = {};
$scope.loading = {
state: false
}
$scope.errors = '';
$scope.email = "";
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}]);
我已经创建了我的模板指定控制器取消功能还是它给error.I采用NG-点击=取消()里面的LoginController按钮。
需要帮助?
I have created the cancel function in the controller which I specify with the template still it gives error.I use ng-click="cancel()" in button inside LoginController .Need help?
推荐答案
您似乎实例与模态视图NG控制器指令控制器。相反,你只需要使用模态的控制器
选项以获得特殊的依赖性 $ modalInstance
注射。如果您已经使用 NG-控制器=LoginController中
实例化控制器,您需要删除它,你不会需要它,以及控制器将自动实例化(通过解决特殊依赖 $ modalInstance
),并连接到模板。
Looks like you are instantiating the controller with ng-controller directive in the modal view. Instead you only need to use controller
option of the modal in order to get the special dependency $modalInstance
injected. If you have instantiated controller using ng-controller="LoginController"
you need to remove it and you would not need it as well as the controller would automatically be instantiated (by resolving special dependency $modalInstance
) and attached to the template.
这篇关于未知提供商:$ modalInstanceProvider< - $ modalInstance在Angularjs模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!