angular 样式属性绑定
<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 样式属性绑定的更多相关文章
- angular的属性绑定
1. 图片地址属性绑定 html文件 <img [src]="imgUrl"> ts文件 export class ProductComponent implement ...
- angular HTML属性绑定
- angular Dom属性绑定
- 黑马vue---17、vue中通过属性绑定绑定style行内样式
黑马vue---17.vue中通过属性绑定绑定style行内样式 一.总结 一句话总结: 如果属性名中带有短线必须加引号,比如: h1StyleObj: { color: 'red', 'font-s ...
- 黑马vue---16、vue中通过属性绑定为元素设置class类样式
黑马vue---16.vue中通过属性绑定为元素设置class类样式 一.总结 一句话总结: 这里就是为元素绑定class样式,和后面的style样式区别一下 vue中class样式绑定方式的相对于原 ...
- 怎样在 Vue 里面绑定样式属性 ?
在 Vue 里绑定样式属性可以使用 v-bind:class="" 和 v-bind:style="" , 二者都可以接受 变量 / 数组 / 对象. 不同点是 ...
- angular 组件学习-组件内属性绑定
#组件内的属性(元素的属性)绑定(property binding) 应用场景:通过改变DOM元素的属性,动态显示/隐藏一个元素 知识点:HTML 属性与DOM属性的区别 改变HTMl属性,浏览器需要 ...
- angular常用属性大全
Angular元素属性大全 addClass()-为每个匹配的元素添加指定的样式类名 after()-在匹配元素集合中的每个元素后面插入参数所指定的内容,作为其兄弟节点 append()-在每个匹配元 ...
- Angular数据双向绑定
Angular数据双向绑定 AngularJS诞生于2009年,由Misko Hevery 等人创建,后为Google所收购.是一款优秀的前端JS框架,已经被用于Google的多款产品当中.Angul ...
随机推荐
- Spring缓存源码剖析:(二)CacheManager
一.CacheManager总览 如果需要Spring缓存可以正常工作,必须配置一个CacheManager. CacheManager实现类你可以配置Spring-context本身提供的Simpl ...
- java成神之——线程操作
线程 Future CountDownLatch Multithreading synchronized Thread Producer-Consumer 获取线程状态 线程池 ThreadLocal ...
- oracle 11g 导出空表
正常情况下,oracle11g的 exp命令无法导出空表,弥补这个缺陷的方法是 在空表创建之前,更改系统设置: show parameter deferred_segment_creation 查看, ...
- windows网络服务之配置网络负载均衡(NLB)群集
O首页51CTO博客我的博客 搜索 每日博报 社区:学院论坛博客下载更多 登录注册 家园 学院 博客 论坛 下载 自测 门诊 周刊 读书 技术圈 曾垂鑫的技术专栏 http:// ...
- webpack4+vue2+axios+vue-router的多页+单页混合应用框架
VUE2的单页应用框架有人分享了,多页应用框架也有人分享了,这里就分享一个单页和多页的混合应用框架吧,初现雏形,还有很多需要优化和改善的地方... 结尾有github地址. 项目结构 │ ├─buil ...
- Apache Hive 建表操作的简单描述
客户端连接hive [root@bigdata-02 bin]# ./beeline Beeline version by Apache Hive beeline: Connecting : Ente ...
- java Web 过滤器Filter详解
简介 Filter也称之为过滤器,Web开发人员通过Filter技术,对web服务器管理的所有web资源:例如Jsp, Servlet, 静态图片文件或静态 html 文件等进行拦截,从而实现一些特殊 ...
- Python和其他语言的区别 (简单精辟啊 手打)
首先是简单 读和写非常容易 免费 免费且开源 社区为专业人士和初学者提供知识和经验的分享交流平台 兼容性 与多平台兼容 面向对象 支持面向对象编程 php面向网络 函数库 python 社区创建了丰富 ...
- C++——STL容器
序列式容器:vector,list,deque:stack,queue(容器适配器),heap,priority_queue,slist 关联式容器:(底层都是红黑树)set,map,multiset ...
- Newtonsoft 序列化和反序列化特殊处理
1>序列化,时间格式化处理 JsonConvert.SerializeObject(Iar, new JsonSerializerSettings() { DateFormatString = ...