angular
angular copied to clipboard
Intent to Deprecate: ElementRef
The ElementRef
API existed entirely to abstract away the DOM in early versions of Angular:
abstract class ElementRef {
dynamic get nativeElement;
}
AngularDart only supports running in the browser, and nativeElement
is always (dart:html
) Element
, which requires manual type casting or unsafe dynamic access to use. As of an earlier version of AngularDart, we added support for injecting Element
or HtmlElement
directly:
import 'dart:html';
import 'package:angular/angular.dart';
@Component(selector: 'comp', template: '')
class Comp {
Comp(HtmlElement element);
}
We're proposing formally deprecating ElementRef
. All uses can be replaced like above.