var app = angular.module('damnit.example.observer', ['ngRoute']); app.config(function($locationProvider, $routeProvider) { $locationProvider.html5Mode(true).hashPrefix('!'); $routeProvider .when('/', { controller: 'FooController as ctrl', template: '

this is foo

' }) .otherwise('/'); }); app.service('regService', [function(){ var observers = []; return { 'register': function(scope) { observers.push(scope); }, 'broadcast': function(data) { var i; for(i=0; i