Angular JS / data handling / overview page

http://stackoverflow.com/questions/17412764/angular-js-data-handling-overview-page

by moderndegree

HTML

<div ng-app="myApp">
    <a href="#one">one</a> | <a href="#two">two</a>
    <div ng-view></div>
    <script id="one.html" type="text/ng-template"><div><h1>Template One</h1>foo = {{shared.foo}}</div></script>
    <script id="two.html" type="text/ng-template"><div><h1>Template Two</h1>foo = {{shared.foo}}</div></script>
</div>

JavaScript

angular.module('myApp', []).config(function($routeProvider){
    $routeProvider.
    when('/one', {templateUrl: 'one.html', controller: 'OneCrtl'}).
	when('/two', {templateUrl: 'two.html', controller: 'TwoCrtl'}).
	otherwise({redirectTo: '/one'});
}).service('sharedService', [function() {
  this.foo = 'bar';
}]).controller('OneCrtl', function($scope, sharedService){
    $scope.shared = sharedService
}).controller('TwoCrtl', function($scope, sharedService){
    $scope.shared = sharedService
});