Gha*_*han 2 modal-dialog twitter-bootstrap angularjs angular-ui-bootstrap
我正在使用 angular bootstrap ui modal,它工作正常,但是当我尝试使用 modalInstance 关闭它时,它给出了上述错误。这是我的代码
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');
};
}]);
Run Code Online (Sandbox Code Playgroud)
我在我用模板指定的控制器中创建了取消函数,但它仍然给出错误。我在 LoginController 内的按钮中使用 ng-click="cancel()" 。需要帮忙?
看起来您正在模态视图中使用 ng-controller 指令实例化控制器。相反,您只需要使用controller
模态选项即可$modalInstance
注入特殊的依赖项。如果您使用实例化了控制器ng-controller="LoginController"
,则需要将其删除,并且您不需要它,因为控制器会自动实例化(通过解析特殊依赖项$modalInstance
)并附加到模板。
归档时间: |
|
查看次数: |
6229 次 |
最近记录: |