I am new to AngularDart and I want to focus the first input on page (with my attribute from decorator) but I can't figure out how to do this. This is my decorator:
import 'dart:html' as html;
import 'dart:async';
import 'package:angular/angular.dart';
@Decorator(selector: '[autofocus]')
class InputFocus implements AttachAware {
final html.InputElement element;
InputFocus(html.Element this.element) {
element.onFocus.listen((_) => print('element focused'));
}
@Override
attach() {
element.focus();
}
}
When I click on the element the message is printed so the element is the on I am looking for. Somehow the element isn't focused on attach cause the message isn't printed when I reload the page. How can I achieve my goal? Maybe there is another approach to reach the element when the DOM is rendered?
Thanks in advance!