角@Input值来自哪里?

时间:2019-07-30 19:01:58

标签: angular

我有一个有角的@Input设置器。而且我不确定它的价值从何而来?

我假设此@Input值来自其父级。而且我为其父级属性设置了一个setter。但是失败了,它不是来自它的父母。但是它来自包装器。

// attribute.component.html
<attribute-error [errors]="control.errors" [style.visibility]="(control.errors && (control.dirty || control.touched)) ? 'inherit' : 'hidden'"></attribute-error>
// attribute-error.component.ts
  @Input('errors') public set errors(inputValue: ErrorTypes) {
    this._errors = inputValue;
    this.hasErrors = inputValue ? !!Object.keys(inputValue).length : false;

调用堆栈跟踪

// Wrapper_AttributeErrorComponent.check_errors
// SharedModule/AttributeErrorComponent/wrapper.ngFactory.js
// I cannot find this file in the project, where it is coming from
Wrapper_AttributeErrorComponent.prototype.check_errors = function(currValue,throwOnChange,forceUpdate) {
  var self = this;
  if ((forceUpdate || jit_checkBinding2(throwOnChange,self._expr_0,currValue))) {
    self._changed = true;
    self.context.errors = currValue;

预期从父组件errors注入attribute.component.html

0 个答案:

没有答案