var app = angular.module('plunker', ['ui.router', 'ui.bootstrap']);
app.config(function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise("/");
$stateProvider
.state('index', {
url: '/',
template: '<h2>Hello world</h2>'
})
.state('terms', {
url: '/terms',
})
})
/**
* Use a run block to ensure the modal will open from anywhere in the app.
**/
app.run(function ($rootScope, $modal) {
/**
* Listen to the `$stateChangeStart` event
*/
$rootScope.$on('$stateChangeStart', function (event, toState) {
/**
* if the new state is not "terms", then ignore it
*/
if(toState.name !== 'terms') return;
/**
* Open the modal window
*/
$modal.open({
template: [
'<div class="modal-content">',
'<div class="modal-header">',
'<h3 class="modal-title">Regulamin</h3>',
'</div>',
'<div class="modal-body">',
'$1. Give us all your money!',
'</div>',
'<div class="modal-footer">',
'<button class="btn btn-primary" ng-click="$dismiss()">OK</button>',
'</div>',
'</div>'
].join(''),
controller: function($scope){
// Do whatever you need here.
}
});
/**
* Prevent the transition to the dummy state, stay where you are
*/
event.preventDefault();
})
})
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.25/angular.js" data-semver="1.2.25"></script>
<script src="//cdn.jsdelivr.net/angular.ui-router/0.2.11/angular-ui-router.js"></script>
<script src="//cdn.jsdelivr.net/angular.bootstrap/0.11.0/ui-bootstrap-tpls.js"></script>
<script src="app.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
</head>
<body>
<ui-view></ui-view>
<a ui-sref="terms">Terms and conditions</a>
</body>
</html>
/* Put your css in here */