Justin Castillo
Justin Castillo

Reputation: 95

What is the difference between decorator syntax @Input('someValue') and @Input() in Angular 4?

I have not been clear what the difference between the two types of syntax is, thank you in advance

Upvotes: 3

Views: 73

Answers (2)

Jjj
Jjj

Reputation: 155

In addition to @Aravind post this is also the case for @Output and @ViewChild directives.

Upvotes: 1

Aravind
Aravind

Reputation: 41581

@Input() will not have any alias naming.

  • Example

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

@Input('someValue') will take alias as someValue

  • Example

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

Explanation when you use alias make sure that you are using the alias in the HTML template.

Upvotes: 4

Related Questions