<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. 分表分库之二:唯一ID的生成方法

    一.为什么要全局唯一? 我们在对数据库集群作扩容时,为了保证负载的平衡,需要在不同的Shard之间进行数据的移动, 如果主键不唯一,我们就没办法这样随意的移动数据.起初,我们考虑采用组合主键来解决这个 ...

  2. Java-Runoob:Java switch case

    ylbtech-Java-Runoob:Java switch case 1.返回顶部 1. Java switch case 语句 switch case 语句判断一个变量与一系列值中某个值是否相等 ...

  3. chrome浏览器,调试详解,调试js、调试php、调试ajax

    1.可以看到js报错 2.可以看到php报错 3.可以看到ajax返回的信息,以及报错情况 4.可以看到调用了那些内容以及顺序 5.可以调试js代码 6.可以查看session等等 功能非常之强大. ...

  4. Sqoop导出MySQL数据

    导入所有表: sqoop import-all-tables –connect jdbc:mysql://ip:port/dbName --username userName --password p ...

  5. ASP.NET页面传值加号变空格解决办法

    只需要把欲传值进行编码 string EncodeId = Server.UrlEncode(id); 加号就变成了 % 2 B  (中间无空格) 然后再传出去. Request.QueryStrin ...

  6. getpass密码隐藏

    使用getpass模块对输入的字符进行隐藏输入 #-*- coding:utf-8 -*- __author__ = "MuT6 Sch01aR" import getpass u ...

  7. java成神之——MySQL Connector/J 的基本使用

    使用示例 DBCP连接池 结语 使用示例 public class demo { static Connection con = null; static Statement st = null; s ...

  8. Storm集群部署及单词技术

    1. 集群部署的基本流程 集群部署的流程:下载安装包.解压安装包.修改配置文件.分发安装包.启动集群 注意: 所有的集群上都需要配置hosts vi  /etc/hosts 192.168.239.1 ...

  9. Spring AOP面向切面编程详解

    前言 AOP即面向切面编程,是一种编程思想,OOP的延续.在程序开发中主要用来解决一些系统层面上的问题,比如日志,事务,权限等等.在阅读本文前希望您已经对Spring有一定的了解 注:在能对代码进行添 ...

  10. leetcode452

    public class Solution { public int FindMinArrowShots(int[,] points) { // multidimensional array cann ...