dart - How to set focus for element on page load? -


i new angulardart , want focus first input on page (with attribute decorator) can't figure out how this. decorator:

import 'dart:html' 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 click on element message printed element on looking for. somehow element isn't focused on attach cause message isn't printed when reload page. how can achieve goal? maybe there approach reach element when dom rendered?

thanks in advance!

some delay should help

new future.delayed(const duration(milliseconds: 50), () => element.focus()); 

Comments