concept html template in category angular

appears as: HTML template, HTML templates, n HTML template
Getting MEAN with Mongo, Express, Angular, and Node.js 2ED

This is an excerpt from Manning's book Getting MEAN with Mongo, Express, Angular, and Node.js 2ED.

When you’re using Express in this way, a few template options are available, including Jade, EJS, Handlebars, and Pug. The basic workflow of a template engine is creating the HTML template, including placeholders for data, and then passing it some data. Then the engine compiles the template and data together to create the final HTML markup that the browser will receive.

8.2.4. Using class member data in the HTML template

As a quick recap, you’ve already seen how to bind data exposed from the component class in the HTML template by using curly braces—as in {{title}}. Now your data is a little more complex, and you need to access the properties of the class member, which you can do by using the standard JavaScript dot syntax. location.name, for example, gives you the value of the name property.

The next listing highlights some of the quick and easy changes to make to the HTML template to bring the data in.

Listing 8.9. Binding the first pieces of data in home-list.component.html
<div class="card">
  <div class="card-block">
    <h4>
      <a href="/location/{{location._id}}">{{location.name}}</a>
      <small>&nbsp;
        <i class="far fa-star"></i>
        <i class="far fa-star"></i>
        <i class="far fa-star"></i>
        <i class="far fa-star"></i>
        <i class="far fa-star"></i>
      </small>
      <span class="badge badge-pill badge-default float-
      right">{{location.distance}}km</span>
    </h4>
    <p class="address">{{location.address}}</p>
    <div class="facilities">
      <span class="badge badge-warning">hot drinks</span>
      <span class="badge badge-warning">food</span>
      <span class="badge badge-warning">power</span>
    </div>
  </div>
</div>


!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":3,\"ch\":25},{\"line\":3,\"ch\":60}],[{\"line\":12,\"ch\":13},{\"line\":12,\"ch\":34}],[{\"line\":14,\"ch\":23},{\"line\":14,\"ch\":43}]]"}
!@%STYLE%@!

Here, you have four single pieces of data being bound into the HTML template. The facilities and the star rating are going to take a bit more work. Start with the facilities, and loop through an array of data.