The component template - lordoftheflies/angular-essential-training GitHub Wiki

When angular finds a match in the Dom for a component selector, it will render the component markup into that Dom element that it found a match on. The markup it will inject comes from the component metadata template properties. There are two options for this; template or template URL. In the app and setting it to a string value of some markup. This is an inline template. The markup is declared within the component metadata. If we switch over to the browser and take a look at the runtime results by inspecting the Dom, we can see that the element named MW dash app has the markup from the metadata inserted inside of it. Back in the code, we can change that markup in the template metadata property and add some new content like a P tag with a description of what the media tracker app is all about. And back in the browser, we can see that our new content is there. Using the template metadata property is an easy way to compose our angular components and we can use back ticks around the inline template value here, instead of single quotes, and start moving things to multiple lines for better readability. The other metadata property we can use is the template URL. This property allows us to specify a file that contains the template content. Angular will load that template file for us and do the same content rendering. We can create a new file named app dot component dot HTML in the app folder to hold the template. And we can grab the markup from the template property and paste it into the new file. Then we can go back to the app dot component dot ts file and change the template property to be template URL. And set that equal to the relative path to the app dot component dot HTML file we just created. So in single quotes we can use the