【问题标题】:What is the difference between decorator syntax @Input('someValue') and @Input() in Angular 4?Angular 4 中的装饰器语法 @Input('someValue') 和 @Input() 有什么区别?
【发布时间】:2018-02-25 21:10:34
【问题描述】:

我一直不清楚这两种语法有什么区别,提前谢谢

【问题讨论】:

    标签: angular typescript decorator


    【解决方案1】:

    @Input() 不会有任何别名命名。

    • 例子

       @Input() student:any[];
       <component [student]="...">
      

    @Input('someValue') 将别名作为 someValue

    • 例子

      @Input('studentInfo') student:any[];
      
      <component [studentInfo]="...">
      

    使用别名时的说明请确保您在 HTML 模板中使用别名。

    【讨论】:

    • @JustinCastillo 很高兴帮助你
    【解决方案2】:

    除了@Aravind 帖子之外,@Output@ViewChild 指令也是如此。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-02
      • 1970-01-01
      • 2020-11-30
      • 1970-01-01
      • 2022-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多