我有一个组件需要从Dart代码访问其根元素。通过在SO上阅读Differences between Angular.js and Angular.dart?,并在AngularDart源代码中寻找,我发现我需要的是为构造函数提供显式类型的参数。如果其中一个参数的类型为dom.Element
,则它将被Angular注入器引用到我的组件根目录。 (未能对构造函数的参数结果类型的异常NoSuchMethodError : method not found: 'simpleName'
正从角内部深处泛起)我的代码现在看起来像这样:AngularDart依赖注入是如何工作的?
@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源代码中,喷油器的配置如何?