title: update scope variable from a promise inside a directive controller
body: <p>I am a newbie to angular. I am trying to populate the map.markers array existing in a controller from a controller of a directive(from a promise inside it).. and having hard time figuring out.  any help is appreciated</p>
  
  <pre><code>var locationController = function ($scope, $http, AppModesService, limitToFilter, uiGmapGoogleMapApi) { //
          var latestMasterYear = AppModesService.getLatestMasterYear();
          uiGmapGoogleMapApi.then(function (maps) { $scope.googleVersion = maps.version; });
          $scope.map = {
                  center: {
                      latitude: 40.0000, 
                      longitude: -98.0000,
                  },
                  zoom: 7,
                  bounds: {},
                  markers : []
          };
  </code></pre>
  
  <p>Directive code:</p>
  
  <pre><code>     app.directive('referencePoints', function () {
              return {
                  restrict: 'E',
                  scope: {
                      routeID: '@routeID',
                      road: '=',
                      openStatus: '=',
                      markers: '='
                  },
                  template: "{{routeID}}&lt;div ng-repeat='point in refResults'&gt;{{point.RoadName}}&lt;/div&gt;",
                  controller: function ($scope, $http, AppModesService) {
                      $scope.refResults;
                      $scope.isItOpen = true;
                      $scope.refResults = $http.get(AppModesService.getRisApiUrlPrefix() + 'GetReferencePoints?routesID=' + $scope.road + '&amp;limited=true').then(
                              function (response) {
                                  $scope.refResults = response.data;
  // This is where the problem starts .. Should I inject $scope.markers here or not?
                                  $scope.generateMarkers(response.data, $scope.markers)
                                  //return response.data;
                              });
                      var generateMarkers = function (data, markers) {
                          for (i = 0; i &lt; data.length; i++) {
                              var record = data[i];
                              var marker = {
                                  latitude: record.Lat,
                                  longitude: record.Long,
                                  title: record.RoadName,
                                  id: record.ID
                              };
                              markers.push(marker);
                          }
                          return markers;
                      };
                      $scope.generateMarkers = function(data, scope){
                          generateMarkers(data, scope);
                      };
                      //$scope.refPoints = $scope.referencePoints(routeID);
                  }
              }
          });
  </code></pre>
  
  <p>...</p>
  
  <pre><code> &lt;reference-points ng-if="isItOpen" markers="markers" road=road.id route-ID="{{road.text}}"/&gt;
  </code></pre>
  
  <p>....</p>
  
  <p>Another directive : </p>
  
  <pre><code>&lt;ui-gmap-google-map center="map.center" zoom="map.zoom"&gt;
      &lt;ui-gmap-markers models="map.markers" coords="'self'" icon="'icon'"&gt;
  
      &lt;/ui-gmap-markers&gt;
  &lt;/ui-gmap-google-map&gt;
  </code></pre>
  
  <p>I am unable to populate the markers to the map from the directive controller. Please help</p>