title: Angular JS promise in service not updating view
body: <p>I am using following code,</p>
  
  <p>=======================================</p>
  
  <h1>HTML</h1>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en" ng-app="eventsApp"&gt;
  &lt;head&gt;
  &lt;META charset="UTF-8"&gt;
      &lt;title&gt;Event Registration&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="/css/app.css"&gt;
  &lt;/head&gt;
  &lt;body ng-clock&gt;
  &lt;div class="container"&gt;
  &lt;div class="navbar"&gt;
      &lt;div class="navbar-inner"&gt;
          &lt;ul class="nav"&gt;
              &lt;li&gt;&lt;a href="/app/NewEvent.html"&gt;Create Event&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
  
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div ng-controller="EventController" style="padding-left:20px; padding-right:20px"&gt;
      &lt;div id="me"&gt;
          &lt;img data-ng-src="{{event.imageUrl}}" alt="{{event.name}}"/&gt;
          &lt;br /&gt;
          &lt;br /&gt;
          &lt;button type="button" class="btn btn-primary" ng-click="scrollToSession()"&gt;Scroll&lt;/button&gt;
  
          &lt;div class="row"&gt;
              &lt;div class="span11"&gt;
                  &lt;h2&gt;{{event.name}}
                  &lt;/h2&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
              &lt;div class="span3"&gt;
                  &lt;div&gt;&lt;strong&gt;Date:&lt;/strong&gt; {{event.date}}&lt;/div&gt;
                  &lt;div&gt;&lt;strong&gt;Time:&lt;/strong&gt; {{event.time}}&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="span4"&gt;
                  &lt;address&gt;
                      &lt;strong&gt;Address:&lt;/strong&gt;&lt;br/&gt;
                      {{event.location.address}}&lt;br/&gt;
                      {{event.location.city}}, {{event.location.province}}
                  &lt;/address&gt;
              &lt;/div&gt;
  
          &lt;/div&gt;
  
          &lt;hr/&gt;
  
          &lt;h3&gt;Sessions&lt;/h3&gt;
          Order By:
          &lt;select ng-model="sortorder" class="input-small"&gt;
              &lt;option selected value="name"&gt;Name&lt;/option&gt;
              &lt;option value="-upVoteCount"&gt;Votes&lt;/option&gt;
          &lt;/select&gt;
          Show:
          &lt;select ng-model="query" class="input-medium"&gt;
              &lt;option selected value=""&gt;All&lt;/option&gt;
              &lt;option value="introductory"&gt;Introductory&lt;/option&gt;
              &lt;option value="intermediate"&gt;Intermediate&lt;/option&gt;
              &lt;option value="advanced"&gt;Advanced&lt;/option&gt;
          &lt;/select&gt;
          &lt;ul class="thumbnails"&gt;
              &lt;li ng-repeat="session in event.sessions | filter:query | orderBy:sortorder" 
                  class="span11" id="session{{session.id}}"&gt;
                  &lt;div class="row session"&gt;
                      &lt;div class="span0 well votingWidget"&gt;
                          &lt;div class="votingButton" ng-click="upVoteSession(session, event)"&gt;
                              &lt;i class="icon-chevron-up icon-white"&gt;&lt;/i&gt;
                          &lt;/div&gt;
                          &lt;div class="badge badge-inverse"&gt;
                              &lt;div&gt;{{session.upVoteCount}}&lt;/div&gt;
                          &lt;/div&gt;
                          &lt;div class="votingButton" ng-click="downVoteSession(session, event)"&gt;
                              &lt;i class="icon-chevron-down"&gt;&lt;/i&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="well span9" ng-click="navigateToDetails(event)" style=" height:100%; overflow: hidden;"&gt;
                          &lt;h4 class="well-title"&gt;{{session.name}} &lt;button type="button" class="btn" ng-show="allowUserToEditSession(session)" ng-click="editSession(session)" style="margin-left:10px;"&gt;Edit&lt;/button&gt;&lt;/h4&gt;
                          &lt;h6 style="margin-top:-10px;"&gt;{{session.creatorName}}&lt;/h6&gt;
                          &lt;span&gt;Duration: {{session.duration | durations}}&lt;/span&gt;&lt;br /&gt;
                          &lt;span&gt;Level: {{session.level}}&lt;/span&gt;
  
                          &lt;p&gt;{{session.abstract}}&lt;/p&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  
  
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;script src="/lib/jquery-2.0.3.min.js"&gt;&lt;/script&gt;
  
  
  &lt;script src="/lib/angular/angular.js"&gt;&lt;/script&gt;
  &lt;script src="/lib/angular/angular-resource.js"&gt;&lt;/script&gt;
  &lt;script src="/lib/angular/angular-resource.min.js"&gt;&lt;/script&gt;
  &lt;script src="/lib/underscore.js"&gt;&lt;/script&gt;
  &lt;script src="/js/app.js"&gt;&lt;/script&gt;
  &lt;script src="/js/filters.js"&gt;&lt;/script&gt;
  &lt;script src="/js/controllers/EventController.js"&gt;&lt;/script&gt;
  &lt;script src="/js/services/EventData.js"&gt;&lt;/script&gt;
  &lt;script src="/lib/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>=======================================</p>
  
  <h1>CONTROLLER CLASS</h1>
  
  <pre><code>eventsApp.controller('EventController',
  function EventController ($scope, eventData) {
  
      $scope.sortorder = 'name';
  
      $scope.event = eventData.getEvent();
  
  
  
      $scope.upVoteSession= function (session) {
          session.upVoteCount++;
      };
  
      $scope.downVoteSession = function (session) {
          session.upVoteCount--;
      };
  }
  );
  </code></pre>
  
  <p>===============================</p>
  
  <h1>SERVICE CLASS</h1>
  
  <pre><code>eventsApp.factory('eventData', function ($resource, $q) {
  var resource = $resource('/data/event/:id', {id:'@id'});
  return{
      getEvent : function () {
          var deferred = $q.defer();
          resource.get({id:1}, 
              function (event) {
                  deferred.resolve(event);
              },
              function (response) {
                  deferred.reject(response);
              });
  
              return deferred.promise;
      },
      save: function (argument) {
          // body...
          var deferred = $q.defer();
          event.id=5;
          resource.save(event, 
              function function_name (response) { deferred.resolve(response); },
              function function_name (response) { deferred.reject(response);  }
              );
          return deferred.promise;
      }
  };
  });
  </code></pre>
  
  <p>=====================================</p>
  
  <h1>JSON DATA From File /data/event/:id'</h1>
  
  <pre><code>  {"id":1,"creator":"jmcooper","name":"Code Camp","date":"03/15/2013","time":"9:00am - 5:00pm","location":{"address":"123 Wall St","city":"New York","province":"NY"},"imageUrl":"http://blog.laptopmag.com/wpress/wp-content/uploads/2012/08/Code-Camp_sf.jpg","sessions":[{"id":1,"upVoteCount":0,"creator":"jmcooper","name":"How To Program","track":"DevOps","duration":1,"abstract":"this session will teach you to program","creatorName":"Jim Cooper","level":"advanced"},{"id":2,"upVoteCount":0,"creator":"jmcooper","name":"How To Dance","track":"Web","duration":4,"abstract":"this session will teach you to dance","creatorName":"Jim Cooper","level":"introductory"},{"id":3,"upVoteCount":0,"creator":"bob","name":"How To Sing","track":"DevOps","duration":1,"abstract":"this session will teach you to sing  Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum  Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum  Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum Lorum Ipsum FooBarsum ","level":"advanced","creatorName":"Bob"},{"duration":2,"name":"How To Be Awesome","abstract":"this course will make me rich","creator":"bob","creatorName":"Bob","id":4,"upVoteCount":0,"track":"Web","level":"introductory"},{"duration":2,"track":"Web","name":"How to build Angular Applications","abstract":"This session is all about angular applications","creator":"bob","creatorName":"Bob","upVoteCount":0,"id":5,"level":"intermediate"}]}
  </code></pre>
  
  <p>The issue I am facing here is, Angular's latest version do not allow to implement promise as it was used previosuly. in documentation, they says, to implement promise, you must need to apply promise to scope. 
      $scope.apply();</p>
  
  <p>With <strong>$resource</strong> only i am getting my template update, but with <strong>$resource and $q promise</strong> template is <strong>Empty</strong></p>
  
  <p>My Question here is, How to manage scope within controller and service, and if we need to manage scope at both level, then what is benefit of Service? Can anyone help me to explain, how this can be achieve using best practice or quality code?</p>
  
  <p>Issue I am facing is, Marked objects are not getting value and representing null as shown in image below.</p>
  
  <p>thanks.</p>