I can return an object, but not the object property. Why? I have tried many things but nothing seems to work. Sorry but I'm new in Angular
app.factory('myData', function() {
var data = {
product: ''
};
function addItem(value) {
data.product = value;
}
function getList() {
return data.product;
}
return {
addItem: addItem,
getList: getList
};
});
Updated with the controllers functions
function controllerA(myData){
var scope = this;
scope.total = 0;
scope.addMore = function(){
scope.total++;
myData.addItem(scope.total);
}
}
function controllerB(myData){
var scope = this;
scope.total = 0;
scope.total = myData.getList();
}
getList()you getundefinedor''?