我有一个组件需要从 Dart 代码中访问其根元素。通过阅读Angular.js 和 Angular.dart 之间的差异?在 SO 上并在 AngularDart 源代码中四处寻找我发现我需要的是提供一个带有显式类型参数的构造函数。如果其中一个参数具有 type dom.Element
,它将由 Angular 注入器提供对我的组件根目录的引用。(在构造函数参数上没有类型会导致NoSuchMethodError : method not found: 'simpleName'
从 Angular 内部深处抛出异常。)我的代码现在看起来像这样:
@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);
…
}
与ng
和dom
存在
import 'package:angular/angular.dart' as ng;
import 'dart:html' as dom;
现在的问题。我如何最好地发现喷油器反应的那些特殊类型?
此外,我想知道:它是否记录在某处?在哪里?如果不是,那么在 AngularDart 源中,注入器在哪里被配置为像这样运行?