Passing ngFor variable to an ngIf template

后端 未结 4 444
清酒与你
清酒与你 2020-12-10 02:41

How do I pass the current variable in an ngFor loop to ngIf, if it is using templates with then/else syntax?

It appears that they pass through fine when used inline,

4条回答
  •  半阙折子戏
    2020-12-10 03:04

    Here are couple more (similar) options for multiple arguments, this one includes using 'ngTemplateOutletContext' and also a condition (in 4th argument - for fun).

    ... should work by copy and paste ...

                
        

    Context arguments demo name: {{cDemoName}}
    . . . . . Context index: {{cIx}}
    . . . . . Context item: --- {{ cItem }} ---
    . . . . . Context is-even: {{ cIsEven }}

提交回复
热议问题