AngularJS: De uma fábrica, como posso chamar outra função
Preciso mover minha função getTemplates do retorno ou o quê?
Exemplo: Eu não sei o que substituir "XXXXXXX" com (eu tentei "this / self / templateFactory" etc ...):
.factory('templateFactory', [
'$http',
function($http) {
var templates = [];
return {
getTemplates : function () {
$http
.get('../api/index.php/path/templates.json')
.success ( function (data) {
templates = data;
});
return templates;
},
delete : function (id) {
$http.delete('../api/index.php/path/templates/' + id + '.json')
.success(function() {
templates = XXXXXXX.getTemplates();
});
}
};
}
])