2015-05-20 3 views
18

Ich benutze $ ionicPopup.confirm(), aber ich würde gerne "Abbrechen Button" Text ändern. Ist es möglich?

Ich bin mir dessen bewusst .show() Syntax:

buttons: [ 
    { text: 'Cancel' } 
    ] 

Aber es scheint nicht mit .Confirm zu arbeiten() ...

Dank 4 die Hilfe

Antwort

9

UPDATE: auf ionic 1.0.0 ist dies jetzt möglich (http://ionicframework.com/docs/api/service/ $ ionicPopup /)

showConfirm Optionen:

{ 
    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. 
} 

Ja können Sie tun wathever Sie wollen, ionische popup.show verwenden und binden das Ereignis abbrechen.

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

Nach einer Untersuchung auf der ionic popover.confirm function dieser ist nicht möglich, sie zu gestalten. Der Wert von popover.confirm sind Linie fest einprogrammiert 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

Es ist möglich zu tun, können Sie den „Typ“, was in der Schaltfläche

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

im Typ Teil, den Sie Geben Sie Klassenname, und Sie können die Farbe der Schaltfläche ändern.

+0

Opener fragte eine Möglichkeit, Button-Text, nicht Farben. – baxeico

28

zumindest in der neuesten Version von Ionic (1.0.0) können Sie folgendes tun:

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

Hier die relative documentation ist.

Verwandte Themen