我想在我的其他方法中调用 editopenComponentModal
,其显示错误 angular.js:13920 TypeError: Cannot read property 'editopenComponentModal' of undefined
EditCurrentJob(job) {
this.$http.put(properties.job_path + "/"+job.job_id).then(function successCallback(response) {
console.log(response.data);
this.current_job = response.data;
this.editopenComponentModal();
},
function errorCallback(response) {
});
}
editopenComponentModal() {
var modalInstance = this.$uibModal.open({
animation: this.animationsEnabled,
template: require('./Report/editsubmittedinformation.html'),
scope: this.$scope,
size: 'lg'
});
this.$scope.modalInstance = modalInstance;
return modalInstance.result;
}
最佳答案
为此目的使用函数引用,希望这会对您有所帮助。
var vm = this;
vm.editopenComponentModal = editopenComponentModal;
function EditCurrentJob(job) {
$http.put(properties.job_path + "/"+job.job_id).then(function successCallback(response) {
console.log(response.data);
vm.current_job = response.data;
vm.editopenComponentModal();
},
function errorCallback(response) {
});
}
function editopenComponentModal() {
var modalInstance = this.$uibModal.open({
animation: this.animationsEnabled,
template: require('./Report/editsubmittedinformation.html'),
scope: this.$scope,
size: 'lg'
});
this.$scope.modalInstance = modalInstance;
return modalInstance.result;
}
关于javascript - 如何在 $http body angularjs 中调用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41277921/