I am trying to have two controllers share an object, that is, from a view I want to send an object to another view, but I can not get it in the view that receives this object. For this I created a service:
angular.module("panelYerrandApp").service('ItemComercioSV', function () {
// this.comercio = item
this.itemcomercio = [];
this.setItemComercio = function (item) {
this.itemcomercio = item;
}
this.getItemComercio = function () {
return this.itemcomercio;
}
});
In both controllers I inject the service, from one view I assign the item and from the other I recover it but I get 'undefined'. Can this be done?