I have an component that needs to access its root element from the Dart code. By reading Differences between Angular.js and Angular.dart? here on SO and grepping around in the AngularDart source code I figured out that what I need is to provide a constructor with explicitly typed arguments. If one of the arguments has type dom.Element
, it will be given the reference to my components root by the Angular injector. (Failing to have types on the constructor arguments results in an exception NoSuchMethodError : method not found: 'simpleName'
being thrown from deep down in Angular internals.) My code now looks like this:
@ng.NgComponent (
selector: 'math',
templateUrl: 'packages/embarassing_name_of_my_package/math/math_component.html',
publishAs: 'ctrl'
)
class MathComponent {
ng.Scope _scope;
dom.Element _element;
ng.NgModel _ngModel;
ng.NodeAttrs _attrs;
MathComponent(this._scope, this._element, this._ngModel, this._attrs);
…
}
with ng
and dom
being
import 'package:angular/angular.dart' as ng;
import 'dart:html' as dom;
Now the question. How do I best discover those special types that the injector reacts to?
Additionally, I'd like to know: Is it documented somewhere? Where? If not, where in the AngularDart source is the injector being configured to behave like this?