AngularJS: Wie kann ich aus einer Fabrik eine andere Funktion aufrufen?

Muss ich meine getTemplates-Funktion aus der Rückgabe verschieben oder was?

Beispiel: Ich weiß nicht, durch was ich "XXXXXXX" ersetzen soll (Ich habe versucht "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();
                });
            }
        };
    }
])

Antworten auf die Frage(2)

Ihre Antwort auf die Frage