Z
Z
zlodiak2018-06-08 22:38:15
Angular
zlodiak, 2018-06-08 22:38:15

How is @Input passed to the directive?

Please help me understand how a variable is passed to the directive. The fact is that the template looks like this:
@Input() appNgLoopOf: Array<any>;

<div *appNgLoop="let nr of numbers; index as i">
  {{ nr }} - Foo
  Index: {{ i }}
</div>

As you can see, appNgLoopOf is not mentioned anywhere here. However, this value gets into the directive. Full example here .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2018-06-08
@zlodiak

The asterisk unfolds your loop like this

<div appNgLoop let-ng="$implicit" [appNgLoopOf]="numbers" let-i="index">
  {{ nr }} - Foo
  Index: {{ i }}
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question