I have a <side-menu> component in 2.0.0-alpha.13. Currently, to set the open class on the side menu to show/hide it, I have to manually manipulate the dom element:
import {Component, Template, NgElement} from 'angular2/angular2';
@Component({
selector: 'side-menu'
})
@Template({
inline: `<div class="scroll-area">
<content></content>
</div>`
})
class SideMenu {
constructor(@NgElement() el: NgElement) {
this.element = el;
}
//drag logic ommitted...
setOpen(isOpen) {
this.isOpen = isOpen;
this.element.domElement.classList[isOpen ? 'add' : 'remove']('open');
}
}
I'd like to be able to setup a [class.open]="isOpen" binding on my component's element instead of having to do this.
@mhevery suggested injecting @PropertySetter('class.open') setter: Function into the constructor, but that errors when used because the actual setter function tries to set domElement.class.open. And domElement.class does not exist.
I have a
<side-menu>component in 2.0.0-alpha.13. Currently, to set theopenclass on the side menu to show/hide it, I have to manually manipulate the dom element:I'd like to be able to setup a
[class.open]="isOpen"binding on my component's element instead of having to do this.@mhevery suggested injecting
@PropertySetter('class.open') setter: Functioninto the constructor, but that errors when used because the actualsetterfunction tries to setdomElement.class.open. AnddomElement.classdoes not exist.