Below is a directive I am using, where I am trying to update a `template` URL based on a variable in a factory:

```
.directive('poGenericNotification',['errorHandler', function(errorHandler) {
return {
  controller: 'ErmModalCtrl',
  restrict: 'EA',
  scope: {
    title: '=',
    errorList: '=',
    errMsg: '=',
    error: '=',
    info: '=',
    numNotifications: '=',
    messageOverflow: '='
  },
  template: "<div ng-include='getTemplateUrl()' class='generic-notif-container' ng-click='openErm()'></div>",
  transclude: true,
  link: function(scope) {
    scope.$watch(errorHandler.getMostRecentError(), function(mostRecentError) {
      scope.getTemplateUrl = function() {
        if (mostRecentError.type === "Alert") {
          return 'src/alerts/templates/error-alert.html';
        }
        else if (mostRecentError.type === "Info") {
          return 'src/alerts/templates/info-alert.html';
        }
      }
    }, true);
    }
  }
}])

```

Here is the factory it is referencing:

```
.factory('errorHandler', function () {
var errorArray = [];
var mostRecentError = {
  type:'', message: '', timestamp: ''
};
function compareObjs(a,b) {
   //sorting function
}
errorArray.addError = (function (type, message) {
  var timestamp = Date.now();
  errorArray.push({type: type, message: message, timestamp: timestamp});
  errorArray.sort(compareObjs);
  errorArray.generateMostRecentError();
});
//....some functions
errorArray.generateMostRecentError = function() {
  if (errorArray[0].message.length > 138) {
    mostRecentError.message = errorArray[0].message.slice(0, 138) + "...";
    messageOverflow = true;
  } else {
    mostRecentError.message = errorArray[0].message;
    messageOverflow = false;
  }
  mostRecentError.type = errorArray[0].type;
  mostRecentError.timestamp = errorArray[0].timestamp;
  console.log(mostRecentError);
}
errorArray.getMostRecentError = function() {
  console.log(mostRecentError);
  return mostRecentError;
}
return errorArray;
})

```

I want to be able to add/remove errors from other controllers and have it update the directive. Currently, for the initial value the `$watch` `mostRecentError` callback is `undefined`, then it never updates. What have I missed?