Created
January 19, 2012 07:47
-
-
Save goofmint/1638631 to your computer and use it in GitHub Desktop.
AngularJS demo
This file contains hidden or 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
| /* http://docs.angularjs.org/#!angular.service */ | |
| /** | |
| * App service which is responsible for the main configuration of the app. | |
| */ | |
| angular.service('myAngularApp', function($route, $location, $window) { | |
| $route.when('/view1', {template: 'partials/partial1.html', controller: MyCtrl1}); | |
| $route.when('/view2', {template: 'partials/partial2.html', controller: MyCtrl2}); | |
| var self = this; | |
| $route.onChange(function() { | |
| if ($location.hash === '') { | |
| $location.updateHash('/view1'); | |
| self.$eval(); | |
| } else { | |
| $route.current.scope.params = $route.current.params; | |
| $window.scrollTo(0,0); | |
| } | |
| }); | |
| }, {$inject:['$route', '$location', '$window'], $eager: true}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment