Skip to content

Instantly share code, notes, and snippets.

@goofmint
Created January 19, 2012 07:47
Show Gist options
  • Select an option

  • Save goofmint/1638631 to your computer and use it in GitHub Desktop.

Select an option

Save goofmint/1638631 to your computer and use it in GitHub Desktop.
AngularJS demo
/* 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