angular icon indicating copy to clipboard operation
angular copied to clipboard

Intent to Deprecate: ElementRef

Open matanlurey opened this issue 7 years ago • 0 comments

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.

matanlurey avatar Nov 15 '17 17:11 matanlurey