1. 绑定静态属性
<div title='this is a static property for the div '> static property example </div>
2. 绑定动态属性
- 动态属性绑定要用
[]
- // app.component.ts
label='this is a dynamic property for the div'
- // app.component.html
<div [title]='label'> dynamic property example </div>
3. 绑定html
- 绑定解析html, 要用
[innerHTML]
- //app.component.ts
htag='<h2> this is the second level title</h2>'
- // app.component.html
<div [innerHTML]='htag' class='colorh'> dynamic property example </div>
- // app.component.css
.colorh {
color: red;
}
4. 引入图片
<img src='assets/images/001.png' alt='upload failed'>
<img src='http://sdfdfsd'>
// app.component.ts
public picUrl='http://sdsdfdsf'
<img [src]=picUrl>
网友评论