javascript - angular 2: attaching string with property binding -


i'm trying attach string propery binding

for example object is

{   "name": "the walking dead",   "imageurl": "/title/tt1520211/?pf_rd_m=a2fgeluunoqjnl&pf_rd_p=2240084122&pf_rd_r=1q5zrdhsa2zk5s6q31wn&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_1",   "rating": "8.6" }, 

as dont have base url in imageurl field want attach in angular template url

template:

<tbody *ngfor="let prod of products"> <tr >   <td><img [src]="'www.example.com/'+{{prod.imgurl}}" alt=""></td>   <td>{{prod.name}}</td>   <td>{{prod.rating}}</td> </tr>  </tbody> 

i'm trying add example.com imageurl in template field , i'm unable add base url

im expecting url baseurl+path

www.example.com/title/tt1520211/?pf_rd_m=a2fgeluunoqjnl&pf_rd_p=2240084122&pf_rd_r=1q5zrdhsa2zk5s6q31wn&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_1 

you dont have use curly brackets. simple:

<img [src]="'www.example.com/' + prod.imgurl">


<tag [someattr]="somevalue">

in angular means somevalue evaluated (just inside {{}}) , assigned someattr, string part should use quotes in pure js


<tag someattr="somestring">

means somestring parsed template, (you must use {{}} evaluate imgurl) , assigned someattr

in e.g. <img src="www.example.com/{{prod.imgurl}}">


someattr @input() property in component, or htmlelement property,


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -