@markandrewkato wrote:
How can I listen to a change in my variable inside my service so that i can sync it on all of my controllers.
I tried using:
Controller:
$scope.$watch(Room.all(), function (newVal) { console.log('new', newVal); });
Service:
(function(){ 'use strict'; angular.module('starter') .factory('RoomSrv', RoomSrv); RoomSrv.$inject = []; function RoomSrv() { var rooms = {}; return { all: all, }; function all() { return rooms; } } })();
but this returns undefined. It doesn't get my service's data.
Posts: 1
Participants: 1