【问题标题】:Angular 6.1 second @Input not recognizedAngular 6.1 秒 @Input 无法识别
【发布时间】:2019-05-17 15:04:15
【问题描述】:

当我只使用 1 个 @Input(参见下面的 ElementType)时,一切都很好。 但是当我添加第二个@Input(验证提示)时,第一个输入被识别,但第二个不被识别。

@Component({
  selector: 'sh-workspace-header',
  templateUrl: './workspace-header.component.html',
  styleUrls: ['./workspace-header.component.scss']
})
export class WorkspaceHeaderComponent implements OnInit {
  @Input() ElementType: string;
  @Input() ValidationHint: string;  <- Not recognized
  @Output() HeaderEvent = new EventEmitter<WorkspaceHeaderEvent>();

引用此组件的 HTML:

  <div class="heading">
    <sh-workspace-header [ElementType]="'Project'" 
                         [ValidationHint]="'none'" 
                         (HeaderEvent)="catchHeaderEvent($event)" >
    </sh-workspace-header>
  </div>

Chrome 开发工具控制台:

【问题讨论】:

  • 您是否保存了 WorkspaceHeaderComponent 文件?
  • 你能在 stackblitz 上重新创建这个吗?
  • 你有没有在任何模块中添加过这个组件?

标签: angular input


【解决方案1】:

如果你传递一个字符串。您可以通过删除方括号传递普通属性而不是属性绑定。

<sh-workspace-header ElementType="'Project'" ValidationHint="'none'" (HeaderEvent)="catchHeaderEvent($event)" >
</sh-workspace-header>

【讨论】:

    猜你喜欢
    • 2020-07-16
    • 2014-01-11
    • 1970-01-01
    • 2018-01-22
    • 2023-03-06
    • 2020-07-27
    • 2018-11-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多