12
อัปเดต css แบบไดนามิกใน Angular 2
สมมติว่าฉันมีส่วนประกอบ Angular2 //home.component.ts import { Component } from 'angular2/core'; @Component({ selector: "home", templateUrl: "app/components/templates/home.component.html", styleUrls: ["app/components/styles/home.component.css"] }) export class HomeComponent { public width: Number; public height: Number; } ไฟล์ html เทมเพลตสำหรับคอมโพเนนต์นี้ //home.component.html <div class="home-component">Some stuff in this div</div> และสุดท้ายไฟล์ css สำหรับคอมโพเนนต์นี้ //home.component.css .home-component{ background-color: red; width: 50px; height: 50px; } …