angular
angular copied to clipboard
Can't inject InputElement
In angular_forms, we have a number of directives that only match an InputElement. However, because of limitations of the DI system, we can only inject a HtmlElement and cast to InputElement. Otherwise, we get No provider found for InputElement error.
Example:
@Directive(selector: `input[ngModel]`)
class MyInputModel {
final InputElement _element;
MyInputModel.fails(this._element); // This fails!!
MyInputModel.works(HtmlElement element)
: _element = element as InputElement; // This works!
}
To clarify, this would be a new issue - we would treat any subclass of Element as valid.
To clarify further, we either only want to do this for injection or make additional changes to "fix" queries too. Queries are trickier, because we currently don't store elements as anything but Element or HtmlElement. For example, to query InputElement we would need the (static) type to be of InputElement.