Kirtesh Shah
What is a difference between template and templateUrl in the Angular Component?

What is difference between template and templateUrl in the Angular Component?

By Kirtesh Shah in .NET on May 06 2022
  • Jaydeep Patil
    Jun, 2022 6

    According to Angular guidelines if you have a large template then you will use templateurl and put external file path into the component. For example- If you have template code for perticular component is more than 5 to 6 lines then you will go with templateurl and put external html template file path and if you have wanna do some small thing with template like displaying message and something like that then go with template only. Thanks!

    • 0
  • Pranam Bhat
    May, 2022 23

    templateUrl is meant for one liner. If you want to mention the html code in one liner inside .ts file, you can make use of templateUrl.

    For example,

    templateUrl : test.html;

    template is used to write the entire content of html as it is.

    Example:

    template:


    testing

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS