How is the following keyword used in angular2 ng-templates
- What is the purpose of
$implicit
in angular 2 templates? - What is relationship between
let-<attribute>
and$implicit
?
How is the following keyword used in angular2 ng-templates
$implicit
in angular 2 templates? let-<attribute>
and $implicit
?
You can define local variable on
ng-template
throughlet-name
When angular creates template by calling
createEmbeddedView
it can also pass context that will be used insideng-template
Using the key
$implicit
in the context object will set it's value as default. So if we write:and we have template
then we can think about it like
so
foo
will equalvalue
Plunker Example
On the other hand if we have context like:
we have to declare variable like: