Skip to content

Instantly share code, notes, and snippets.

@rinukkusu
Created November 9, 2017 18:43
Show Gist options
  • Save rinukkusu/1cc90fafe18eaa8ba268d5c2a562587a to your computer and use it in GitHub Desktop.
Save rinukkusu/1cc90fafe18eaa8ba268d5c2a562587a to your computer and use it in GitHub Desktop.
import 'dart:html';
import 'package:angular/angular.dart';
import 'package:angular_components/src/components/glyph/glyph.dart';
@Component(
selector: 'toggleMenu',
directives: const [GlyphComponent],
template: r'''
<glyph [icon]="icon" size="x-large"></glyph>{{text}}
''',
styles: const ['''
:host {
cursor: pointer;
}
''']
)
class ToggleMenuComponent implements AfterViewInit {
@Input('element')
DivElement element;
@Input('text')
String text;
String icon = 'keyboard_arrow_right';
ToggleMenuComponent();
@HostListener('click', const ['\$event'])
void onClick(event) {
if (element.style.display == 'none') {
element.style.display = 'block';
icon = 'keyboard_arrow_down';
}
else {
element.style.display = 'none';
icon = 'keyboard_arrow_right';
}
}
@override
ngAfterViewInit() {
element.style.display = 'none';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment