未知提供程序:$modalInstanceProvider<;-$Angularjs模态中的模态
我使用的是angular bootstrap ui模式,工作正常,但当我尝试使用modalInstance关闭它时,会出现上述错误未知提供程序:$modalInstanceProvider<;-$Angularjs模态中的模态,angularjs,twitter-bootstrap,modal-dialog,angular-ui-bootstrap,Angularjs,Twitter Bootstrap,Modal Dialog,Angular Ui Bootstrap,我使用的是angular bootstrap ui模式,工作正常,但当我尝试使用modalInstance关闭它时,会出现上述错误 var app = angular.module('LoginModule', ['ui.bootstrap']); app.controller('LoginModal', ['$scope', '$modal', function ($scope, $modal) { $scope.animationsEnabled = true; $sc
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');
};
}]);
我已经在控制器中创建了cancel函数,我使用模板指定该函数,但它仍然会出错。我在LoginController中的按钮中使用了ng click=“cancel()”。
需要帮助吗?看起来您正在模态视图中使用ng控制器指令实例化控制器。相反,您只需使用模态的
控制器
选项,即可注入特殊的依赖项$modalInstance
。如果您已使用ng controller=“LoginController”
实例化了控制器,则需要将其删除,并且不需要它,因为控制器将自动实例化(通过解决特殊依赖关系$modalInstance
)并附加到模板。是否也使用ng控制器在视图中指定控制器?似乎宋控制器=“LoginController”,ng控制器=“LoginModel”是这样的模式正在打开,我在控制台中看到错误,请参阅我的答案。您不应该将ng controller与LoginController一起使用,因为$modalInsatncecontroller=“LoginController”没有像这样的真正的提供者?@Ghazanfar您已经在您的模式设置中这样做了controller:'LoginController',
所以只需从/app/template/Login.html