我有以下工作正常的控制器:
function Controller() {}
Controller.prototype = {
getResult: function(project) {
var that = this;
jQuery.ajax({
async: false,
url: "/my-service/call?project=" + project,
dataType: "json",
success: function(data) {
that.result = data;
}
});
}
};
我想使用 AngularJS .scope.$bind 来查看是否可以消除 'var that = this;' 黑客。但以下不起作用:
function Controller() {}
Controller.prototype = {
getResult: function(project) {
angular.scope.$bind(jQuery.ajax({
async: false,
url: "/my-service/call?project=" + project,
dataType: "json",
success: function(data) {
this.result = data;
}
}))();
}
};
我错过了什么?