fix(button): apply css for buttons w/ ngIf

Closes #5927
This commit is contained in:
Adam Bradley
2016-07-04 21:26:55 -05:00
parent cac1d4f961
commit 816a6486b0
5 changed files with 10 additions and 12 deletions

View File

@@ -3,7 +3,6 @@ import { Directive, ElementRef, Input } from '@angular/core';
import { AppRoot } from '../app/app';
import { isTrueProperty } from '../../util/util';
const DISABLE_SCROLL = 'disable-scroll';
/**
* @private

View File

@@ -226,7 +226,10 @@ export class Button {
* @private
*/
setRole(val: string) {
this._assignCss(false);
this._role = val;
this._readIcon(this._elementRef.nativeElement);
this._assignCss(true);
}
/**
@@ -350,16 +353,6 @@ export class Button {
}
}
/**
* @private
*/
static setRoles(contentButtonChildren: any, role: string) {
let buttons = contentButtonChildren.toArray();
buttons.forEach((button: any) => {
button.setRole(role);
});
}
}
const BUTTON_SIZE_ATTRS = ['large', 'small', 'default'];

View File

@@ -16,6 +16,7 @@ class E2EPage {
myColor1: string;
myColor2: string;
multiColor: Array<string>;
showIf: boolean = true;
constructor() {
this.reset();

View File

@@ -2,6 +2,7 @@
<ion-toolbar>
<ion-buttons start>
<button danger *ngIf="showIf">ngIf</button>
<button [color]="isDestructive ? 'danger' : 'primary'" [outline]="isOutline">Outline</button>
</ion-buttons>
<ion-title>Default Buttons</ion-title>
@@ -25,6 +26,8 @@
<button block [color]="multiColor" [outline]="isClicked" [round]="isCustom" (click)="toggle()">Multicolor Outline (Toggle)</button>
<button block [color]="multiColor" [clear]="isClicked" [round]="isCustom" (click)="toggle()">Multicolor Clear (Toggle)</button>
<hr/>
<button block outline danger (click)="showIf = !showIf">Toggle Header</button>
<hr/>
<button block outline danger (click)="unify()" class="e2eButtonDynamicUnify">Unify all buttons</button>
<button block clear danger (click)="reset()">Reset all buttons</button>

View File

@@ -27,7 +27,9 @@ export class ToolbarItem {
@ContentChildren(Button)
set _buttons(buttons: any) {
if (this.inToolbar) {
Button.setRoles(buttons, 'bar-button');
buttons.forEach((button: Button) => {
button.setRole('bar-button');
});
}
}
}