我试图在我的工厂内调用另一个功能,但是我收到了这个错误。我做了其他人所说的in this link。我找不到问题。我哪里做错了?谢谢!
.factory('UserPreferences',function(Http,ngDialog,Notification){
var settings = {}
return {
authenticated: false,
settings:{},
saveSettings: function(data){
var data = {
url: '/pointofsale/userpreferences/save',
data: data
}
Http.Post(data)
.success(function(data){
statusMessage = data
ngDialog.closeAll(0)
})
},
authenticate_change_settings: function(user,settings){
this.settings = settings
var data = {
url: '/pointofsale/authenticate_change_settings',
data: user
}
Http.Post(data)
.success(function(data){
if(data){
this.authenticated = true;
this.saveSettings(this.settings);
}
}).error(function(data){
Notification.error(data)
})
}
}
更新:所以我发现了问题,我无法调用该功能 $ http post call成功函数。为什么会这样?
所以,我试过这样做。它起作用,它称之为功能。不确定这是否合适。
authenticate_change_settings: function(user){
var $this = this;
var data = {
url: '/pointofsale/authenticate_change_settings',
data: user
}
Http.Post(data)
.success(function(data){
if(data){
$this.authenticated = true;
$this.saveSettings(this.settings);
}
}).error(function(data){
Notification.error(data)
})
}