2015-05-20 13 views
18

Używam $ ionicPopup.confirm(), ale chciałbym zmienić tekst "Anuluj przycisk". Czy to możliwe?

Jestem świadomy .Show() składnia:

buttons: [ 
    { text: 'Cancel' } 
    ] 

Ale to nie wydają się działać z .Przyciskiem() ...

Thank 4 pomoc

Odpowiedz

9

UPDATE: na jonowej 1.0.0, jest to obecnie możliwe (http://ionicframework.com/docs/api/service/ $ ionicPopup /)

showConfirm Opcje:

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

Tak można zrobić każdej pojemności chcesz, używając jonową popup.show i powiązać zdarzenie Anuluj.

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

Po przeprowadzeniu dochodzenia w sprawie tego ionic popover.confirm function jest nie można go dostosować. Wartość popover.confirm są sztywno linia 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

Jest to możliwe do zrobienia, trzeba użyć "typ" rzeczy wewnątrz przycisku

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

w typu części, którą muszą nadać klasie nazwę klasy i można zmienić kolor przycisku przycisku.

+0

Opener poprosił o sposób dostosowania tekstu przycisku, a nie kolorów. – baxeico

28

Przynajmniej w najnowszej wersji 1.0.0 (jonowej) można wykonać następujące czynności:

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

Oto relative documentation.

Powiązane problemy