title: SammyJS with AngularJS
body: <p>I have problems using Sammy with Angular.</p>
  
  <p>I have this application module</p>
  
  <pre><code>var appModule = angular.module('myApp', []).run(function (routes) {
      routes.run('#/');
  });
  </code></pre>
  
  <p>And this service</p>
  
  <pre><code>appModule.factory('routes', function ($rootScope) {
  
      var routes = $.sammy(function () {
  
          this.get('#/room/:roomId', function () {
              var that = this;
              setTimeout(function () {
                  $rootScope.$broadcast('user has entered the room', {roomId: that.params['roomId']});
              }, 1000);
  
          });
  
      });
  
      return routes;
  });
  </code></pre>
  
  <p>I need this <code>setTimeout</code> because I don't know when $rootScope is accessible. When I put low interval number in <code>setTimeout</code>, event doesn't broadcasted. One second interval works OK, but I don't want such ugly solutions. How can I be sure that $rootScope is ready and I can launch url handler function?</p>