Подтвердить что ты не робот

Можно ли изменить текст кнопки с помощью $ionicPopup.confirm()?

Я использую $ionicPopup.confirm(), но я бы хотел изменить текст "cancel button". Можно ли это сделать?

Я знаю синтаксис .show():

  buttons: [
  { text: 'Cancel' }
  ]

Но он не работает с .confirm()...

Благодарим 4 помощь

4b9b3361

Ответ 1

По крайней мере, в последней версии Ionic (1.0.0) вы можете сделать следующее:

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

Вот относительная документация .

Ответ 2

UPDATE: on ionic 1.0.0, теперь это возможно (http://ionicframework.com/docs/api/service/ $ionicPopup/)

showConfirm Опции:

{
  title: '', // String. The title of the popup.
  cssClass: '', // String, The custom CSS class name
  subTitle: '', // String (optional). The sub-title of the popup.
  template: '', // String (optional). The html template to place in the popup body.
  templateUrl: '', // String (optional). The URL of an html template to place in the popup   body.
  cancelText: '', // String (default: 'Cancel'). The text of the Cancel button.
  cancelType: '', // String (default: 'button-default'). The type of the Cancel button.
  okText: '', // String (default: 'OK'). The text of the OK button.
  okType: '', // String (default: 'button-positive'). The type of the OK button.
}

Да, вы можете делать все, что захотите, используя ionic popup.show и связать событие Cancel.

$ionicPopup.show({
   template: msg,
   title: titleConfirm,
   buttons: [
     { text: "BTN_NO",
       onTap:function(e){
            return false;
       }
     },
     { text: "BTN_OK",
       onTap:function(e){
            return true;
       }
     },
   ]
});

После исследования функции ionic popover.confirm это его невозможно настроить. Значение popover.confirm - строка с жестким кодом 446

function showConfirm(opts) {
    return showPopup(extend({
      buttons: [{
        text: opts.cancelText || 'Cancel',
        type: opts.cancelType || 'button-default',
        onTap: function() { return false; }
      }, {
        text: opts.okText || 'OK',
        type: opts.okType || 'button-positive',
        onTap: function() { return true; }
      }]
    }, opts || {}));
  }

Ответ 3

Это можно сделать, вы должны использовать "тип" внутри кнопки

buttons: [
            { text: 'Cancel' },
            {
                text: '<b>Save</b>',
                type: 'button-assertive',
                onTap: function(e) {
                    $scope.request_form.abc = "accepted";
                }
            }
        ]

в разделе типа вам нужно указать имя класса, и вы можете изменить цвет кнопки.