Skip to content

Instantly share code, notes, and snippets.

@egel
Created March 3, 2016 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egel/dc55d2f1a3e58a179bb2 to your computer and use it in GitHub Desktop.
Save egel/dc55d2f1a3e58a179bb2 to your computer and use it in GitHub Desktop.
Minimal angular example with ui.router
<!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>
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