在ionic官网文档中,提供了一种解决$ionicPopup.show的buttons修改方式:

var myPopup = $ionicPopup.show({
    template: '<input type="password" ng-model="data.wifi">',
    title: 'Enter Wi-Fi Password',
    subTitle: 'Please use normal things',
    scope: $scope,
    buttons: [
      { text: 'Cancel' },
      {
        text: '<b>Save</b>',
        type: 'button-positive',
        onTap: function(e) {
          if (!$scope.data.wifi) {
            //don't allow the user to close unless he enters wifi password
            e.preventDefault();
          } else {
            return $scope.data.wifi;
          }
        }
      }
    ]
  });

但是,当用同样的方式在$ionicPopup.confirm上使用的时候,就不行,虽然可以设置文字,但是当点击的时候返回的是undefined!

var confirmPopup = $ionicPopup.confirm({
    title: 'Consume Ice Cream',
    template: 'Are you sure you want to eat this ice cream?',
    buttons: [
        { text: 'Cancel' },
        {
            text: '<b>Save</b>',
            type: 'button-positive',
            onTap: function(e) {
                if (!$scope.data.wifi) {
                //don't allow the user to close unless he enters wifi password
                    e.preventDefault();
                } else {
                    return $scope.data.wifi;
                }
            }
        }]
    });
        confirmPopup.then(function(res) {
    if(res) {
        console.log('You are sure');
    } else {
        console.log('You are not sure');
    }
});

其实ionic确实提供了confir的buttons修改方式,如下:

cancelText: 'Custom cancel',
okText: 'Custom ok'

如:

var confirmPopup = $ionicPopup.confirm({
    title: 'Popup title',
    template: 'Popup text',
    cancelText: 'Custom cancel',
    okText: 'Custom ok'
}).then(function(res) {
    if (res) {
        console.log('confirmed');
    }
});

用ionicframework做一个小应用,需要取数据,本地测试会遇到跨域问题。

查了好多资料,谷歌百度都用上了,服务器端也修改成*了,就是不起作用,还是提示“XMLHttpRequest cannot load http://xxx/api/feedback/send. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.”

实在没办法了,在模拟机上看又太慢,看ionic官网博客,有一个解决方案,这里继续阅读