AngularJS : Factory $http 赋值返回 null

AngularJS : Factory $http assigning values returning null

尽管请求通过并返回 json.

,但 conf var 为空,我正在尝试从 $http.get() 分配一个变量
app.factory('Config', ['$http',
    function($http) {
        return {

            conf: null,

            init: function () {

                if (this.conf === null) {
                    $http.get('/config')
                        .success(function (data) {
                            this.conf = data;
                        });
                }
            }
        }
    }
]);

this里面success callback function不一样

app.factory('Config', ['$http',
    function($http) {
        return {

            conf: null,

            init: function () {
                var self = this;
                if (this.conf === null) {
                    $http.get('/config')
                        .success(function (data) {
                            self.conf = data;
                        });
                }
            }
        }
    }
]);