Created
March 3, 2016 11:20
-
-
Save egel/dc55d2f1a3e58a179bb2 to your computer and use it in GitHub Desktop.
Minimal angular example with ui.router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html ng-app="project"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.18/angular-ui-router.min.js"></script> | |
<script src="scripts.js"></script> | |
</head> | |
<body> | |
<div ng-controller="AppController"> | |
<h2>Minimal example</h2> | |
<p>{{ currentDate }}</p> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _appController($scope) { | |
$scope.currentDate = new Date() | |
} | |
function _config($urlRouterProvider, $stateProvider) { | |
$stateProvider.state('app', { | |
url: '', | |
controller: 'AppController', | |
templateUrl: 'index.html' | |
}) | |
$urlRouterProvider | |
.when('', '/') | |
.when('/', '/home') | |
} | |
angular.module('project', [ | |
'ng', | |
'ui.router' | |
]) | |
.config(_config) | |
.controller('AppController', _appController); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment