当我更改视图时,我在AngularJS中遇到问题,它将页面变为silhoutte灰色/黑色,整个页面被冻结或禁用。没有什么可以点击的。您需要手动刷新它才能再次恢复正常。控制台中也没有错误日志。如何解决?
angular.module('myApp.loginController', [])
.controller('LoginController', function($scope, $state) {
$scope.loginSubmit = function(){
$state.go('customer_home');
}
$scope.reset = function(){
$scope.loginData = {};
}
});
main.html中
...some codes here...
<button type="submit" class="btn btn-default" ng-click="loginSubmit()">Login</button>
...some codes here...
这是在更改视图后冻结的页面外观
答案 0 :(得分:0)
修复方法是使用$ uibModal服务。 BS模态的传统方式在AngularJS中不是一种方便的方法。然后在$ uibModal的控制器中注入$ uibModalInstance然后使用close函数。要了解更多信息,请参阅服务的文档:http://angular-ui.github.io/bootstrap/#/modal
很抱歉,更不用说main.html代码是BS模式的一部分,因为起初我认为它不会导致任何错误。
main.html中
...some codes here...
<script type="text/ng-template" id="loginModal" ng-controller="LoginController">
<div id="loginModalCont" class="modal-content">
<div class="modal-header">
<button type="button" class="close" ng-click="close()">×</button>
<h4 class="modal-title">LOG IN</h4>
</div>
<form ng-model="loginData">
<div class="modal-body">
<div class="form-group">
<label for="username">Username:</label>
<input type="username" class="form-control" id="username" ng-model="loginData.username">
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" class="form-control" id="password" ng-model="loginData.password">
</div>
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="loginSubmit()">Login</button>
<button type="button" class="btn btn-default" data-dismiss="modal" data-toggle="modal" data-target="#signupModal">Signup</button>
<button type="reset" class="btn btn-default" ng-click="reset()">Clear</button>
</div>
</form>
</div>
</script>
mainController.js
.controller('MainController', function($scope, $location, $anchorScroll, $uibModal) {
...some codes here...
$scope.openModal = function(){
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'loginModal',
controller: 'LoginController'
});
}
});
loginController.js
.controller('LoginController', function($scope, $state, $uibModalInstance) {
$scope.loginSubmit = function(){
$state.go('member_home');
$uibModalInstance.close();
}
$scope.reset = function(){
$scope.loginData = {};
}
$scope.close = function(){
$uibModalInstance.close();
}
});