[Angular Tutorial] 8-templating Links & Images

Source: Internet
Author: User

In this step, we'll add a thumbnail to the phone list and attach a link, which of course will not be linked to now. In the next steps, we'll use these links to show additional information in the phone list.

• There will be links and pictures in the phone list now.

The most important differences are listed below. You can click here to view all the differences on GitHub.

Data

note phones Span class= "pun" > json file contains the unique ID and picture URLs for each phone. These URLs point to app / img / phones / directory.

app/phones/phones.json(Sample code snippet):

[  {    ...    " ID ":" Motorola-defy-with-motoblur ","    imageUrl ":" Img/phones/motorola-defy-with-motoblur.0.jpg ",    " name " : "Motorola defy\u2122 with motoblur\u2122",    ...  },  ...]

Component templates

app/phone-list/phone-list.template.html:

... <ul class= "Phones" >  <li ng-repeat= "phone in $ctrl. Phones | filter: $ctrl. Query | orderby:$ Ctrl.orderprop "class=" thumbnail ">    <a href=" #/phones/{{phone.id}} "class=" thumb ">          </a>    <a href= "#/phones/{{phone.id}" >{{ phone.name}}</a>    <p>{{phone.snippet}}</p>  </li></ul>, ....

in order to dynamically generate a link to the phone Detail page in the future, we use the double curly brace bindings that are now quite familiar as href property value. In the 2nd step, we added {{ phone name }} binding as the element content. In this step {{phone id}   bindings are used in element attributes.

{{ < Span style= "Background-color: #c0c0c0;" >&NBSP;EXPRESSION&NBSP, tag, Also block to an illegal URL ( http: //localhost:8000/{{phone.imageurl}} ) Send the request. If we just use an ordinary SRC tag, this step will be executed. By using NGSRC instruction , we blocked the browser from sending HTTP requests to illegal destinations.

Summarize

Now that you've added images and links to your phone, let's move on to the next step to learn angular layout templates and see how angular makes it easy to create apps that have a lot of emphasis on graphs.

[Angular Tutorial] 8-templating Links & Images

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.