Hey Arnaud,

On 07.11.2017 09:15, Arnaud Deman wrote:



In the associated component you just need something like :
@Input() tikersymbol: string;

As you use two way binding the value will be updated when the user enter a 
value.
Here is the angular doc : 
https://angular.io/guide/template-syntax#two-way-binding---


You don't need @Input() there. Input annotation is required when you expect 
that this component will get input from it's parent component, not from the 
template itself. In this case, a simple *tickersymbol: string;* will bind 
the value in the form template to the value on the component.

It would still work with Input, but it's creating extra bindings. Input 
gives you the ability to do something like this:

@Component({
  selector: 'my-cmp',
  ...
})
export class MyCmp {
  @Input() tickerSymbol:string;
}


// another component which users MyCmp
@Component({
  selector: 'parent-cmp',
  template: `
<p>This is the parent template using MyCmp as child component.
It gives it "tickerSymbol" as input.
</p>

<my-cmp [tickerSymbol]="'IBM'"></my-cmp>


Like I've said, this still works in the particular case, but the 
`tickerSymbol` on component where it's been annotated with @Input would 
change not only when the form value changes, but also when the value 
changes on the parent. It's used for different purposes.

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to