ionic2/3 ngClass 和ngStyle用法
2017-07-12 09:53
369 查看
ngClass第一个参数为类名称,第二个参数为boolean值,如果为true就添加第一个参数的类
ngStyle没有判断
ngStyle有判断
例如:
[ngClass]="{'text-success':index == 0}"
ngStyle没有判断
<div [ngStyle]="{'background-color':'green'}"></<div>
ngStyle有判断
<div [ngStyle]="{'background-color':username === 'zxc' ? 'green' : 'red' }"></<div>
例如:
<ion-col col-4 *ngFor="let item of rmpp ;let i = index" (click)="choose(item.id)"> <button id="{{item.id}}" ion-button small outline [ngClass]="{'active':i === 0}">{{item.name}}</button></ion-col>
<ion-col col-4 *ngFor="let item of rmpp ;let i = index" (click)="choose(item.id)"> <button id="{{item.id}}" ion-button small outline [n 4000 gStyle]="{'color':i=== 0 ? 'green' : 'red' }">{{item.name}}</button></ion-col>
相关文章推荐
- ionic之使用ng-class控制样式
- Ionic 的 ng-class 在聊天功能上面的巧妙运用
- Ionic 的 ng-class 在聊天功能上面的巧妙运用
- Ionic 的 ng-class 在聊天功能上面的巧妙运用
- ng-class ionic
- ng-class几种写法
- ionic ngRepeat追加数据(加载更多,不需要重复渲染dom数据)
- ng-class ng-style
- ionic ng-bind-html
- AngularJS中关于ng-class指令的几种实现方式详解
- Angular ng-class详解及实例代码
- angularjs学习笔记--ng-class的三种使用方法
- IDEA下ClassNotFoundException: org...dispatcher.ng.filter.StrutsPrepareAndExecuteFilter错误的解决
- angularjs ng-class 两种用法
- ngclass expressions in angularjs
- ionic 利用ng-bind-htm中且后台返回html代码中图片宽高固定解决办法
- ng-class用法
- Angular—ng-class
- Ionic之button标签ng-click无反应解决
- IDEA13中配置struts错误:ClassNotFoundException: org...dispatcher.ng.filter.StrutsPrepareAndExecuteFilter +找不到java程序包 解决办法