angular5之DOM绑定和html绑定

1)DOM绑定
(一般是事件绑定)

html

component
doInput(event:any){console.log(event.target.value)
}

2)html绑定
(一般是class,style,attr属性绑定)

(-----------------------------属性绑定-----------------------------------------)
html中------   //给td绑定collapse属性
html属性绑定html属性绑定
component中-----size=3;(---------------------class绑定-----------------------------------------)html中-------

class全部属性绑定

class属性部分绑定

使用[ngClass]绑定属性

css中------ .bg{ background:blue;} .fontSize:{ font-size:20px;} .colorStyle{ color:red}component中------ ngClassStyle:any={bg:false,colorStyle:false,fontSize:false } isTrue:boolean=false;constuctor(){setTimeout(()=>{this.divClass = ''bg fontSize colorStyle"this.isTrue=true;this.ngClassStyle={bg:true,fontSize:true,colorStyle:true}},3000)}(style绑定)

1111

222

3333

component中------isStyle:any={fontSize:'19px',color:'red',background:'yellow'}

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部