2014-09-26 22 views
0

我有弹出演示工作简单,但现在已经调用弹出窗口中按钮的onclick上的api。如何使用IONIC和AngularJs在POPUP中的onclick上调用api?

此代码采用两个按钮与默认名称,我想更改按钮的名称。

$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'); 
      }); 
      } 

请告诉我如何能弹出式按钮调用API上的onclick并更改按钮的名称....

回答

0

你要在这里服务创建您拨打电话到API,然后在你的控制器你打电话给那个服务,最后从你看来你打电话给控制器。我建议你开始寻找

1)服务 - 2)控制器和$范围

1

要叫你需要服务的API。内置的$ http服务适用于简单的调用。你可以像其他任何东西一样注入它。 $http.get('/api/somewhere').then(etc..$http.post('/api/somewhere')只会去你的console.log目前的位置。有关更多信息,请参阅$http documentation

你得到更先进的你要抽象这些调用到自己的服务,您可以用app.service('myService', function(){ //methods in your service });

定义