These are chat archives for angular/angular-2-ionic-2

20th
Mar 2015
Andrew Joslin
@ajoslin
Mar 20 2015 14:27

Say we have a button component. It has an attribute available called look that sets a class depending on the given value. For example, you could do:

<ion-button look="3d-button">Button</button>
<ion-button look="ios-button">Button 2</button>

Depending on the value of the look attribute, we want to add a class ios-button or 3d-button to the button when its component is instantiated.

The problem with this is that if the developer has hundreds of <ion-button> components, adding the class to the button after it's already in the DOM is expensive.

Is there a way we could access the component's element before it's in the DOM and add these classes to it?

Miško Hevery
@mhevery
Mar 20 2015 19:09
@ajoslin angular/angular#1008
Andrew Joslin
@ajoslin
Mar 20 2015 21:53
@mhevery that's not exactly what i meant. I mean I want access to the host element before it's attached to the DOM in some cases
is this even doable? if a <my-button> is in a parent component's template, is there a way angular knows it's a <my-button> before it hits the DOM?
I don't want my dom manipulations to cause repaints if possible
Miško Hevery
@mhevery
Mar 20 2015 21:54
angular/angular#521
I don't think it would cause repaints.