pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<i id='5muYW'><tr id='5muYW'><dt id='5muYW'><q id='5muYW'><span id='5muYW'><b id='5muYW'><form id='5muYW'><ins id='5muYW'></ins><ul id='5muYW'></ul><sub id='5muYW'></sub></form><legend id='5muYW'></legend><bdo id='5muYW'><pre id='5muYW'><center id='5muYW'></center></pre></bdo></b><th id='5muYW'></th></span></q></dt></tr></i><div class="98ks36t" id='5muYW'><tfoot id='5muYW'></tfoot><dl id='5muYW'><fieldset id='5muYW'></fieldset></dl></div>
        <bdo id='5muYW'></bdo><ul id='5muYW'></ul>
      <tfoot id='5muYW'></tfoot>

    1. <small id='5muYW'></small><noframes id='5muYW'>

    2. <legend id='5muYW'><style id='5muYW'><dir id='5muYW'><q id='5muYW'></q></dir></style></legend>

        如何在角度2中動(dòng)態(tài)更改css類名

        How to change the css class name dynamically in angular 2(如何在角度2中動(dòng)態(tài)更改css類名)

        • <small id='DnY7D'></small><noframes id='DnY7D'>

              <tbody id='DnY7D'></tbody>
              <bdo id='DnY7D'></bdo><ul id='DnY7D'></ul>
              <legend id='DnY7D'><style id='DnY7D'><dir id='DnY7D'><q id='DnY7D'></q></dir></style></legend>

              1. <i id='DnY7D'><tr id='DnY7D'><dt id='DnY7D'><q id='DnY7D'><span id='DnY7D'><b id='DnY7D'><form id='DnY7D'><ins id='DnY7D'></ins><ul id='DnY7D'></ul><sub id='DnY7D'></sub></form><legend id='DnY7D'></legend><bdo id='DnY7D'><pre id='DnY7D'><center id='DnY7D'></center></pre></bdo></b><th id='DnY7D'></th></span></q></dt></tr></i><div class="3d3twq7" id='DnY7D'><tfoot id='DnY7D'></tfoot><dl id='DnY7D'><fieldset id='DnY7D'></fieldset></dl></div>

                • <tfoot id='DnY7D'></tfoot>
                  本文介紹了如何在角度2中動(dòng)態(tài)更改css類名的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我有兩個(gè)CSS類名如下

                  .icon_heart{顏色:#bdbdbd;}.icon_heart_red{顏色:#a6b7d4;;}

                  我的 HTML 有一個(gè)心形圖標(biāo)

                  <div class="icon_heart" *ngIf="showheartIcon">

                  這里我有兩個(gè) div 標(biāo)簽,心形圖標(biāo)最初是灰色,點(diǎn)擊后我會(huì)將其更改為藍(lán)色.

                  這是我的 ts 文件代碼:

                   showheartIcon=true;showheartIconRed =假;setWishlistTrue(id){this.showheartIconRed = true;this.showheartIcon = false;}setWishlistFalse(id){this.showheartIconRed = false;this.showheartIcon = true;}

                  我有兩個(gè)不同顏色的圖標(biāo).

                  問題

                  是否可以更改圖標(biāo)的類別而不是兩個(gè)心形圖標(biāo)?

                  我在 JavaScript 中看到我們可以更改它w3schools 簡(jiǎn)單的方法將類應(yīng)用于 div 標(biāo)簽,但我是 TypeScript 的新手.如何更改班級(jí)?

                  解決方案

                  <div [ngClass]="showheartIconRead ? 'icon_heart_red' : 'icon_heart'">

                  I have two CSS class name as follows

                  .icon_heart{
                       color: #bdbdbd;
                  }
                  
                  .icon_heart_red{
                      color:#a6b7d4;;
                  }
                  

                  My HTML has a heart icon

                  <div class="icon_heart" *ngIf="showheartIcon">
                      <ion-icon name="heart" (click)="setWishlistTrue(category.product_id);" class="heart"></ion-icon>
                  </div>
                  <div class="icon_heart_red" *ngIf="showheartIconRed">
                      <ion-icon name="heart" (click)="setWishlistFalse(category.product_id);" class="heart"></ion-icon>
                  </div>
                  

                  Here I have two div tags, the heart icon is of gray color initially and on clicking that I will change it to blue color.

                  Here is my ts file code:

                    showheartIcon=true;
                    showheartIconRed =false;
                  
                    setWishlistTrue(id){
                      this.showheartIconRed = true;
                      this.showheartIcon = false;
                    }
                  
                    setWishlistFalse(id){
                      this.showheartIconRed = false;
                      this.showheartIcon = true;
                    }
                  

                  I have two icons of different color.

                  Question

                  Instead of having two heart icons is it possible to change the class of the icon?

                  I have seen in JavaScript we can change it w3schools simple way to apply class to the div tag, but I am new to TypeScript. How can I change the class?

                  解決方案

                  <div 
                      [class.icon_heart]="!showheartIconRead"
                      [class.icon_heart_red]="showheartIconRead">
                  

                  or

                  <div [ngClass]="showheartIconRead ? 'icon_heart_red' : 'icon_heart'">
                  

                  這篇關(guān)于如何在角度2中動(dòng)態(tài)更改css類名的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項(xiàng)目中不起作用)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動(dòng)態(tài)元素 - Angular 2 amp;離子2)
                  How to reload the ion-page after pop() in ionic2(如何在 ionic2 中的 pop() 之后重新加載離子頁面)
                  Retrieve localstorage value when value is change in Ionic 2(當(dāng) Ionic 2 中的值發(fā)生變化時(shí)檢索本地存儲(chǔ)值)

                  1. <tfoot id='QQGXq'></tfoot>
                        <tbody id='QQGXq'></tbody>

                      <small id='QQGXq'></small><noframes id='QQGXq'>

                        • <bdo id='QQGXq'></bdo><ul id='QQGXq'></ul>

                        • <legend id='QQGXq'><style id='QQGXq'><dir id='QQGXq'><q id='QQGXq'></q></dir></style></legend>
                          <i id='QQGXq'><tr id='QQGXq'><dt id='QQGXq'><q id='QQGXq'><span id='QQGXq'><b id='QQGXq'><form id='QQGXq'><ins id='QQGXq'></ins><ul id='QQGXq'></ul><sub id='QQGXq'></sub></form><legend id='QQGXq'></legend><bdo id='QQGXq'><pre id='QQGXq'><center id='QQGXq'></center></pre></bdo></b><th id='QQGXq'></th></span></q></dt></tr></i><div class="6basusz" id='QQGXq'><tfoot id='QQGXq'></tfoot><dl id='QQGXq'><fieldset id='QQGXq'></fieldset></dl></div>

                            主站蜘蛛池模板: 玻纤土工格栅_钢塑格栅_PP焊接_单双向塑料土工格栅_复合防裂布厂家_山东大庚工程材料科技有限公司 | 派财经_聚焦数字经济内容服务平台| NMRV减速机|铝合金减速机|蜗轮蜗杆减速机|NMRV减速机厂家-东莞市台机减速机有限公司 | 警用|治安|保安|不锈钢岗亭-售货亭价格-垃圾分类亭-移动厕所厂家-苏州灿宇建材 | 绿叶|绿叶投资|健康产业_绿叶投资集团有限公司 | 河南中专学校|职高|技校招生-河南中职中专网 | 气动球阀_衬氟蝶阀_调节阀_电动截止阀_上海沃托阀门有限公司 | 河南不锈钢水箱_地埋水箱_镀锌板水箱_消防水箱厂家-河南联固供水设备有限公司 | sus630/303cu不锈钢棒,440C/430F/17-4ph不锈钢研磨棒-江苏德镍金属科技有限公司 | 巩义市科瑞仪器有限公司| 深圳装修_店面装修设计_餐厅设计_装修全包价格-尚泰装饰设计 | 托盘租赁_塑料托盘租赁_托盘出租_栈板出租_青岛托盘租赁-优胜必达 | 翅片管散热器价格_钢制暖气片报价_钢制板式散热器厂家「河北冀春暖气片有限公司」 | 河南包装袋厂家_河南真空袋批发价格_河南服装袋定制-恒源达包装制品 | 智能化的检漏仪_气密性测试仪_流量测试仪_流阻阻力测试仪_呼吸管快速检漏仪_连接器防水测试仪_车载镜头测试仪_奥图自动化科技 | FFU_空气初效|中效|高效过滤器_空调过滤网-广州梓净净化设备有限公司 | 防水套管厂家_刚性防水套管_柔性防水套管_不锈钢防水套管-郑州中泰管道 | 北京易通慧公司从事北京网站优化,北京网络推广、网站建设一站式服务商-北京网站优化公司 | 密集架|电动密集架|移动密集架|黑龙江档案密集架-大量现货厂家销售 | 减速机三参数组合探头|TSM803|壁挂式氧化锆分析仪探头-安徽鹏宸电气有限公司 | 定硫仪,量热仪,工业分析仪,马弗炉,煤炭化验设备厂家,煤质化验仪器,焦炭化验设备鹤壁大德煤质工业分析仪,氟氯测定仪 | 定坤静电科技静电消除器厂家-除静电设备 | EPK超声波测厚仪,德国EPK测厚仪维修-上海树信仪器仪表有限公司 | 辐射色度计-字符亮度测试-反射式膜厚仪-苏州瑞格谱光电科技有限公司 | 没斑啦-专业的祛斑美白嫩肤知识网站-去斑经验分享 | 砂磨机_立式纳米砂磨机_实验室砂磨机-广州儒佳化工设备厂家 | SMC-SMC电磁阀-日本SMC气缸-SMC气动元件展示网 | 山东艾德实业有限公司 | 东莞工作服_东莞工作服定制_工衣订做_东莞厂服 | 合肥宠物店装修_合肥宠物美容院装修_合肥宠物医院设计装修公司-安徽盛世和居装饰 | 高博医疗集团上海阿特蒙医院| 精密线材测试仪-电线电缆检测仪-苏州欣硕电子科技有限公司 | 环氧乙烷灭菌器_压力蒸汽灭菌器_低温等离子过氧化氢灭菌器 _低温蒸汽甲醛灭菌器_清洗工作站_医用干燥柜_灭菌耗材-环氧乙烷灭菌器_脉动真空压力蒸汽灭菌器_低温等离子灭菌设备_河南省三强医疗器械有限责任公司 | Maneurop/美优乐压缩机,活塞压缩机,型号规格,技术参数,尺寸图片,价格经销商 | 超声波破碎仪-均质乳化机(供应杭州,上海,北京,广州,深圳,成都等地)-上海沪析实业有限公司 | 山东PE给水管厂家,山东双壁波纹管,山东钢带增强波纹管,山东PE穿线管,山东PE农田灌溉管,山东MPP电力保护套管-山东德诺塑业有限公司 | 杭州顺源过滤机械有限公司官网-压滤机_板框压滤机_厢式隔膜压滤机厂家 | 艺术涂料_进口艺术涂料_艺术涂料加盟_艺术涂料十大品牌 -英国蒙太奇艺术涂料 | TPU薄膜_TPU薄膜生产厂家_TPU热熔胶膜厂家定制_鑫亘环保科技(深圳)有限公司 | 模具硅橡胶,人体硅胶,移印硅胶浆厂家-宏图硅胶科技 | 珠海冷却塔降噪维修_冷却塔改造报价_凉水塔风机维修厂家- 广东康明节能空调有限公司 |