I want a service which can share/auto sync data to 2 or more controllers like this example:
app.js (from example)
var myApp = angular.module('myApp', []);
myApp.factory('Data', function(){
return { FirstName: '' };
});
myApp.controller('FirstCtrl', function( $scope, Data ){
$scope.Data = Data;
});
myApp.controller('SecondCtrl', function( $scope, Data ){
$scope.Data = Data;
});
Furthermore I need to load the data with ajax. I tried a bit but for ajax I need the promise (so the controller dont get changed data after init) which dont worked with the shared object like the fiddle link. If possible I want a solution without events (rootscope broadcast).
How can i use both techniques together? Do you guys know what I mean? :)