FreeOZ论坛
标题:
angular 2 css class name
[打印本页]
作者:
DDD888
时间:
16-6-2017 19:00
标题:
angular 2 css class name
https://www.npmjs.com/package/ng2-responsive
在angular 2 项目里使用ng2-responsive,如何根据isMobile来设置css class name i.e. <p class="*isMoble mobileFontClass"></p>
<p class="*isDesktop desktopFontClass"></p>?
谢谢
作者:
DDD888
时间:
17-6-2017 20:17
我来回答我自己的问题
先要在自己的component里
import {ResponsiveState} from 'ng2-responsive';
isMobile: Boolean
constructor(private responsiveState: ResponsiveState) {
this.isMobile = responsiveState.userAgent_data().mobile.state
}
html template里
<div [ngClass]="{'center': !isMobile }">
欢迎光临 FreeOZ论坛 (https://www.freeoz.org/ibbs/)
Powered by Discuz! X3.2