How to monitoring a varible which is in a "service" module inside of a "directive" module. I have a Service module.
angular
.module('SGA')
.service('messageService', [messageService]);
function messageService() {
var ctrl = this;
this.messages = [];
this.send = function (message, type) {
ctrl.messages.push({ text: message, type: type });
};
And i have a Directive module
angular.module('SGA').directive('message', function () {
return {
restrict: 'E',
scope: {},
bindToController: {
msg: '@'
},
templateUrl: "assets/templates/message/message.html",
controllerAs: 'ctrl',
link: function (){}
}
})
I want that when the variable "messages " to change the directive module is changed and sent the new value for templateUrl. I need to be always monitoring the variable because when she gets something , I need to show on the page