2018年7月30日 星期一
Angular2 Learning Note (4):How to control div style through Angular2
1. Assign backgroud image
Use [style.xxx] directly
<div class="Layout" [style.background-image]="backgroundImg">
</div>
Meet error message: something like trust issue
Add this into app.component.ts
this.backgroundImg = this.sanitizer.bypassSecurityTrustStyle('url(' + this.IndoorLayoutPath + ')');
Check detail in
https://stackoverflow.com/questions/34875426/how-to-add-background-image-using-ngstyle-angular2/34875479
2. To adjust the location of div
<div *ngFor="let rList of RoomList" (click)="assignFacility(rList.name, rList.facility._id, rList.facility.name)">
<div class="RoomInLayout" *ngIf="rList.facility.name==fList.facility.name"[style.top.px]="rList.x" [style.left.px]="rList.y">
>{{rList.name}} [x,y]=[ {{rList.x}} ,{{rList.y}}]
</div>
</div>
訂閱:
張貼留言 (Atom)
-
(1) Vector Common method: vector<int> v; vector v(10, 0); // {0,0,0,0,0,0,0,0,0,0} v[i] // acc...
-
Inspire by Leetcode #239 https://leetcode.com/problems/sliding-window-maximum/description/ The purpose is the maintain a queue (FIFO) an...
-
Q: For a given size = n array, how to choose k element fairly? A: This is a rather easy question if n is small. What if the size is unkn...
沒有留言:
張貼留言