如何使用IONIC和AngularJs在onclick-in弹出窗口上调用api?
我有一个简单的弹出演示,但是现在只要点击弹出按钮就可以调用api 这段代码使用两个按钮的默认名称,我想更改按钮的名称如何使用IONIC和AngularJs在onclick-in弹出窗口上调用api?,angularjs,Angularjs,我有一个简单的弹出演示,但是现在只要点击弹出按钮就可以调用api 这段代码使用两个按钮的默认名称,我想更改按钮的名称 $scope.OnAppointment = function() { var confirmPopup = $ionicPopup.confirm({ title: 'My Appointment', }); confirmPopup.then(function(res)
$scope.OnAppointment = function() {
var confirmPopup = $ionicPopup.confirm({
title: 'My Appointment',
});
confirmPopup.then(function(res) {
if(res) {
console.log('You are sure');
} else {
var alertPopup = $ionicPopup.alert({
title: 'Cancle Appointment',
template: 'Are you sure you want to cancle the appointment?'
});
alertPopup.then(function(res) {
console.log('Sucessfully Cancel');
});
}
请告诉我如何在onclick-in弹出按钮上调用api并更改按钮名称……您必须在此处创建服务您对api进行调用,然后在控制器中调用该服务,最后从视图中调用控制器。我建议你开始看看 1) 服务-
2) Controller和$Scope来调用需要服务的API。内置的$http服务适用于简单的调用。你可以像注射其他东西一样注射它<代码>$http.get('/api/somewhere')。然后(etc..或
$http.post('/api/somewhere')
将直接转到console.log当前所在的位置。有关详细信息,请参阅
当您变得更高级时,您会希望将这些调用抽象到您自己的服务中,您可以使用app.service('myService',function(){//methods in your service});