Reputation: 47
I want to call editopenComponentModal
in my other method its show error 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;
}
Upvotes: 0
Views: 59
Reputation: 767
Use the function references for that purpose, jopefully this will help you out.
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;
}
Upvotes: 1
Reputation:
Add var that = this
above the this.$http.put(
Then change:
this.current_job = response.data;
this.editopenComponentModal();
To:
that.current_job = response.data;
that.editopenComponentModal();
Explanation:
this
inside the callback has different context, so you need to save the desired this
to a variable which can be used there.
Here you can read the better explanation: How to access the correct `this` context inside a callback?
Upvotes: 0
Reputation: 1241
If you want to open a modal after $http.put request then use.
$('#success').modal();
here success is the id.
Upvotes: 0