<button (click)="onClick($event)">点我</button>
<input type="text" (input)="onInput($event)" value="">
<table>
<tr>
<td [attr.colspan]="colspan" class="a b" [class.c]="isBool"> 你好</td>
</tr>
</table> <table>
<tr>
<td [ngClass]="ngClassA"> 你好</td>
</tr>
</table> <table>
<tr>
<td [style.color]="isDev ? 'red': 'blue'"> 你好</td>
</tr>
</table> <table>
<tr>
<td [style.font-size.em]="isDev ? 3: 1"> 你好</td>
</tr>
</table> <table>
<tr>
<td [ngStyle]="ngStyleA"> 你好</td>
</tr>
</table>
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-bind',
templateUrl: './bind.component.html',
styleUrls: ['./bind.component.css']
})
export class BindComponent implements OnInit { private colspan = ;
private myclass: string;
private isBool: boolean;
private ngClassA;
private isDev = false;
private ngStyleA; constructor() { } ngOnInit() {
this.ngClassA = {
a: false,
b: false,
c: false
};
this.ngStyleA = {
background: 'yellow',
color: 'red'
};
setTimeout(() => {
this.isBool = true;
this.isDev = true;
this.ngClassA = {
a: true,
b: true,
c: true
};
this.ngStyleA = {
background: 'red',
color: 'yellow'
};
}, );
} onClick($event) {
console.log($event);
}
onInput($event) {
console.log($event.target.value);
console.log($event.target.getAttribute('value'));
}
}
.a{
background: yellow;
}
.b{
color: red;
}
.c{
font-size: 20px;
}

angular 样式属性绑定的更多相关文章

  1. angular的属性绑定

    1. 图片地址属性绑定 html文件 <img [src]="imgUrl"> ts文件 export class ProductComponent implement ...

  2. angular HTML属性绑定

  3. angular Dom属性绑定

  4. 黑马vue---17、vue中通过属性绑定绑定style行内样式

    黑马vue---17.vue中通过属性绑定绑定style行内样式 一.总结 一句话总结: 如果属性名中带有短线必须加引号,比如: h1StyleObj: { color: 'red', 'font-s ...

  5. 黑马vue---16、vue中通过属性绑定为元素设置class类样式

    黑马vue---16.vue中通过属性绑定为元素设置class类样式 一.总结 一句话总结: 这里就是为元素绑定class样式,和后面的style样式区别一下 vue中class样式绑定方式的相对于原 ...

  6. 怎样在 Vue 里面绑定样式属性 ?

    在 Vue 里绑定样式属性可以使用 v-bind:class="" 和 v-bind:style="" , 二者都可以接受 变量 / 数组 / 对象. 不同点是 ...

  7. angular 组件学习-组件内属性绑定

    #组件内的属性(元素的属性)绑定(property binding) 应用场景:通过改变DOM元素的属性,动态显示/隐藏一个元素 知识点:HTML 属性与DOM属性的区别 改变HTMl属性,浏览器需要 ...

  8. angular常用属性大全

    Angular元素属性大全 addClass()-为每个匹配的元素添加指定的样式类名 after()-在匹配元素集合中的每个元素后面插入参数所指定的内容,作为其兄弟节点 append()-在每个匹配元 ...

  9. Angular数据双向绑定

    Angular数据双向绑定 AngularJS诞生于2009年,由Misko Hevery 等人创建,后为Google所收购.是一款优秀的前端JS框架,已经被用于Google的多款产品当中.Angul ...

随机推荐

  1. java代码水仙花

    总结:分离出百位,十位,各位,我总是模模糊糊的,总是分不清取膜与除号的作用区别: “%”的意思是“取膜”,表示取得的是余数 “/”的意思是除,得到的是除数. package com.a; //求水仙花 ...

  2. Windows10 官方原版镜像下载途径 Label:win10解决方案

    https://www.microsoft.com/en-gb/software-download/windows10ISO 设置浏览标签为手机以避免跳转,下载即可  或者手机打开该网址,获取下载链接 ...

  3. 1120 Friend Numbers

    题意:略. 思路:水题,略. 代码: #include <iostream> #include <string> using namespace std; ; }; int m ...

  4. 1107 Social Clusters

    题意:给出n个人(编号为1~n)以及每个人的若干个爱好,把有一个或多个共同爱好的人归为一个集合,问共有多少个集合,每个集合里有多少个人? 思路:典型的并查集题目.并查集的模板init()函数,unio ...

  5. python's twenty_fourth day for me 内置方法

    str  repr: 1,当需要使用__str__的场景时找不到__str__就找__repr__ 2,当需要使用__repr__的场景时找不到__repr__的时候就找父类的repr. 3,双下re ...

  6. 7.solr学习速成之facet

    Facet 介绍   Facet 是 solr 的高级搜索功能之一 ,可以给用户提供更友好的搜索体验,在搜索关键字的同时 , 能够按照 Facet 的字段进行分组并统计.        比如你上淘宝, ...

  7. 如何在老惠普电脑上安装windows xp系统

    如何在老惠普电脑上安装windows xp系统 前提,老式的紧凑的惠普台式机,装了linux系统,想要装windows xp系统另作他用.但是使用U盘PE怎么也进不了? 解决办法: 1.拆下惠普主机上 ...

  8. Java微信公众平台开发(八)--多媒体消息回复

    转自:http://www.cuiyongzhi.com/post/46.html 之前我们在做消息回复的时候我们对回复的消息简单做了分类,前面也有讲述如何回复[普通消息类型消息],这里将讲述多媒体消 ...

  9. delphi 原生 ADODB.recordset

    ADODB.recordset ..\source\rtl\win\Winapi.ADOInt.pas..\17.0\OCX\Servers\ADODB2010.pasCLASS_Recordset: ...

  10. 通过helloworld来认识下backbone

    Backbone主要涉及3部分:model,collection和view.而这个框架的优势在于:数据与视图分离,通过操作model来自动更新view. 根据我的个人经验,直接写个简单的例子是最最直观 ...