0
我已经声明了一个带有三个函数的工厂。我能够调用get函数,但不能用另外两个。函数在angularjs工厂中未定义
todomvc.factory('todoStorage', function ($q,$http) {
var STORAGE_ID = 'todos-angularjs-perf';
function get(){
return $http.get('test.json');
}
function display(){
console.log("testing");
}
function put(todos) {
console.log(todos);
return $http.get('test.json');
}
return{get:get};
return{put:put};
});
在调用控制器的功能,
display(); // undefined here
todoStorage.put(todos); // undefined here too
如果我做了一个错误?
您的工厂认定中是wrong..check http://stackoverflow.com/questions/26906503/passing-arguments -to-工厂/ 26906603#26906603 – Asik 2014-11-21 19:08:46