AngularJS: De una fábrica, ¿cómo puedo llamar a otra función?
¿Tengo que mover mi función getTemplates fuera de la devolución o qué?
Ejemplo: No sé qué reemplazar "XXXXXXX" con (he intentado "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();
});
}
};
}
])