AngularJS: с завода, как я могу вызвать другую функцию
Должен ли я переместить свою функцию getTemplates из возврата или как?
Пример: я не знаю, что заменить "XXXXXXX» с (я пытался "это / Я / templateFactory» так далее... ) :
.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();
});
}
};
}
])