How to reuse template HTML block in Angular?

后端 未结 5 964
野趣味
野趣味 2020-12-23 09:28

Lets suppose we have html block in file:

Text

How can I reuse this html code below in the same file, I m

5条回答
  •  再見小時候
    2020-12-23 09:43

    I might be late to the party. There are some answers though, but I couldn't achieve it with what is described in above answers I still felt that someone might need a bit of direction.

    Key points that are not defined in any of the answers clearly.

    1. Consider you have a template which is binding some values in it. So you have to attach a context object in order make template binding work.

    
        ...
    
    note that let-anyVariableName for template and "paymentInvoices" is the class variable that you are passing.

    in usage

    1. You have to define template first and then use it anywhere you want to. Just think of a function declaration. But until unless you don't call function it wont have any affect.

    Overall code declaration of template

    
      
    {{invoice.invoiceNo }} x

    calling/usage

    You can use it any number of times you want.

提交回复
热议问题