Skip to content

Instantly share code, notes, and snippets.

@nblenke
Created November 15, 2013 15:00
Show Gist options
  • Save nblenke/7485637 to your computer and use it in GitHub Desktop.
Save nblenke/7485637 to your computer and use it in GitHub Desktop.
A one page Angular starter application template
<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<head>
<title>Angular</title>
</head>
<body>
<a href="#!/">Home</a> | <a href="#!/test">Test</a>
<div ng-view></div>
<!-- templates -->
<script id="tmpl-home" type="text/ng-template">
<p>Home</p>
<p>{{Hello}}</p>
</script>
<script id="tmpl-test" type="text/ng-template">
<p>Test</p>
<p>{{Message}}</p>
<p><a href="" ng-click='go()'>click me</a></p>
</script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular-route.min.js"></script>
<script type="text/javascript">
/* app */
angular.module('app', ['ngRoute'])
.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(false).hashPrefix('!');
$routeProvider
.when('/', {
templateUrl: 'tmpl-home',
controller: 'HomeController'
})
.when('/test', {
templateUrl: 'tmpl-test',
controller: 'TestController'
})
.otherwise({
redirectTo: '/'
});
})
.controller('HomeController', function($scope) {
$scope.Hello = 'Hello There!';
})
.controller('TestController', function($scope) {
$scope.Message = 'This is a test.';
$scope.go = function() {
alert('bar');
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment