2017-01-17 24 views
0

我想在我的導航欄中使用切換切換英語和德語之間的語言。ionic2在導航欄中切換使用適當的

<button ion-button menuToggle> 
    <ion-icon name="menu"></ion-icon> 
</button> 

<ion-title>{{ 'CATALOGUE' | translate }}</ion-title> 

<ion-buttons end> 
    <ion-list> 

    <ion-item> 
     <ion-toggle [(ngModel)]="language"></ion-toggle> 
    </ion-item> 

    </ion-list> 
</ion-buttons> 

enter image description here

這基本上長相醜陋。在導航欄中使用這種切換按鈕的正確方法是什麼?

回答

0

我知道這太晚了,但希望它可以幫助任何有類似問題的人。

我使用離子型3,這件事擔任意爲我

在導航欄使用切換按鈕:

<ion-buttons end> 
    <ion-toggle (ionChange)="onToggle($event)" [(ngModel)]="language"></ion-toggle> // ionChange event will fire every time when you change the toggle state 
</ion-buttons> 
0

如果把它裏面<ion-buttons end></ion-buttons>不起作用嘗試使用代替。從離子列表和離子項目中獲取<ion-toggle></ion-toggle>,因爲它們默認爲白色背景,將其放入離子按鈕中。

您還可以通過向其添加類並使其做一些CSS樣式或內聯樣式來使離子項的背景透明。