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...
-
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...
-
給定一個數列,要輸出隨機排列的序列: 方法1. c++提供 next_permutation() http://www.cplusplus.com/reference/algorithm/next_permutation/ 結果: ...


沒有留言:
張貼留言