How the values of obj returned in the factory can access the Local variables or functions. Suppose i want to encapsulate my model as local variable or function in the factory or service but i want to return them as values of return object. But when i'm doing so i getting an error saying that variable not defined.Can any one help me on this problem.
app.factory('myFactory',function(){
var listofFriends=["john","ajay",.....];
var addFriend=function(name){
if(name!==""){
listofFriends.push(name);
};
return listofFriends;};
return{Friends:listofFriends,addfriend:addFriend(name)}
});
gives an error