admin管理员组文章数量:1406974
hi this is my current code where i have popup once i cancel the popup i have to close the entire app tab which means the window
<!doctype html>
<html ng-app="plunker">
<head>
<script src=".2.11/angular.js"></script>
<script src=".10.0.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<script>
angular.module('plunker', ['ui.bootstrap']);
var ModalDemoCtrl = function ($scope, $modal, $log) {
/* Note: The hard coded user object has been mented out, as
it is now passed as an object parameter from the HTML template.
*/
/* $scope.user = {
user: 'name',
password: null
};*/
$scope.open = function (user) {
$scope.user = user;
$modal.open({
templateUrl: 'myModalContent.html',
backdrop: true,
windowClass: 'modal',
controller: function ($scope, $modalInstance, $log, user) {
$scope.user = user;
$scope.submit = function () {
$log.log('Submiting user info.');
$log.log(JSON.stringify(user));
$modalInstance.dismiss('cancel');
}
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
window.open('location', '_self', '');
window.close();
};
},
resolve: {
user: function () {
return $scope.user;
}
}
});
};
};
</script>
<div ng-controller="ModalDemoCtrl">
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header">
<h3>I'm a modal!</h3>
</div>
<form ng-submit="submit()">
<div class="modal-body">
<label>User name</label>
<input type="text" ng-model="user.user" />
<label>Password</label>
<input type="password" ng-model="user.password" />
</div>
<div class="modal-footer">
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
<input type="submit" class="btn primary-btn" value="Submit" />
</div>
</form>
</script>
<button class="btn" ng-click="open({user: 'username', password: 'password'})">Open me!</button>
<div ng-show="user.password">Got back from modal: {{ user | json}}</div>
</div>
</body>
</html>
this code not working any help please
window.close() not working
hi this is my current code where i have popup once i cancel the popup i have to close the entire app tab which means the window
<!doctype html>
<html ng-app="plunker">
<head>
<script src="http://ajax.googleapis./ajax/libs/angularjs/1.2.11/angular.js"></script>
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.10.0.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn./bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<script>
angular.module('plunker', ['ui.bootstrap']);
var ModalDemoCtrl = function ($scope, $modal, $log) {
/* Note: The hard coded user object has been mented out, as
it is now passed as an object parameter from the HTML template.
*/
/* $scope.user = {
user: 'name',
password: null
};*/
$scope.open = function (user) {
$scope.user = user;
$modal.open({
templateUrl: 'myModalContent.html',
backdrop: true,
windowClass: 'modal',
controller: function ($scope, $modalInstance, $log, user) {
$scope.user = user;
$scope.submit = function () {
$log.log('Submiting user info.');
$log.log(JSON.stringify(user));
$modalInstance.dismiss('cancel');
}
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
window.open('location', '_self', '');
window.close();
};
},
resolve: {
user: function () {
return $scope.user;
}
}
});
};
};
</script>
<div ng-controller="ModalDemoCtrl">
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header">
<h3>I'm a modal!</h3>
</div>
<form ng-submit="submit()">
<div class="modal-body">
<label>User name</label>
<input type="text" ng-model="user.user" />
<label>Password</label>
<input type="password" ng-model="user.password" />
</div>
<div class="modal-footer">
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
<input type="submit" class="btn primary-btn" value="Submit" />
</div>
</form>
</script>
<button class="btn" ng-click="open({user: 'username', password: 'password'})">Open me!</button>
<div ng-show="user.password">Got back from modal: {{ user | json}}</div>
</div>
</body>
</html>
this code not working any help please
window.close() not working
Share edited Jun 30, 2016 at 7:57 Gayathri Mohan asked Jun 30, 2016 at 7:50 Gayathri MohanGayathri Mohan 2,9624 gold badges21 silver badges26 bronze badges 6- please refer to plnkr.co/edit/d1VhZhjdBPPEHn2sVJBK?p=preview – Python Basketball Commented Jun 30, 2016 at 8:59
- eon read my question i said need to close the window not the popup – Gayathri Mohan Commented Jun 30, 2016 at 9:01
- what error does it throw? – Python Basketball Commented Jun 30, 2016 at 9:06
- that i gave my code to check , no error – Gayathri Mohan Commented Jun 30, 2016 at 9:09
- could you please have a try to use $window.close()? – Python Basketball Commented Jun 30, 2016 at 10:05
2 Answers
Reset to default 2window.close
will only close the windows opened by application and not the windows/tabs opened by user. that means when user visits your site HE/SHE OPENED the window and not your app. but if u open a new window using javascript using window.open
you can close with window.close
. This is done for security reasons and is inbuilt in almost all latest browsers.
use $window.close()
in $window service.
You are asking about angular modal. use this
$modalInstance.dismiss('cancel'); or $modalInstance.close();
read this for more information modal
本文标签: javascriptwindowclose how to close the current window in angularStack Overflow
版权声明:本文标题:javascript - window.close how to close the current window in angular - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745046825a2639416.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论