What is $implicit in angular 2?

You can define local variables on ng-template through let-name

When angular creates a template by calling createEmbeddedView it can also pass context that will be used inside ng-template

Using the key $implicit in the context object will set its value as default. So if we write:

vcRef.createEmbeddedView(template, { $implicit: 'value' })

and we have the template

<ng-template let-foo> 
 {{ foo }}
</ng-template>

then we can think about it like

<ng-template let-foo="$implicit"> 
  {{ foo }}
</ng-template>

so foo will equal value

Plunker Example

On the other hand, if we have a context like:

{ bar: 'value' }

we have to declare variables like:

let-foo="bar"

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)