转到此StackBlitz 链接( Not Working)
转到此StackBlitz 链接( Working Fine)
我的问题是关于Array.splice. 当数组数据不同时,Array.splice 工作正常,但当数组数据相同时,Array.splice仅删除最后一个索引。在这种情况下,splice 会忽略提供的索引以从数组中删除元素。
这两个示例都有通用的 HTML 模板
<div class="container">
<table class="table table-dark table-striped table-hover">
<thead>
<tr>
<td scope="col"> Index </td>
<td scope="col"> Value </td>
<td scope="col"> Action </td>
</tr>
</thead>
<tbody>
<tr *ngFor="let row of rows; let i = index" [@itemAnim]>
<td> {{i}} </td>
<td>{{row}}</td>
<td><button class="btn btn-danger" (click)="deleteRow(i)">Delete</button></td>
</tr>
</tbody>
</table>
<button class="btn btn-primary " (click)="addRow()">Add row</button>
</div>
Run Code Online (Sandbox Code Playgroud)
请参阅此示例按预期工作:
index …Run Code Online (Sandbox Code Playgroud) I have one question about.. How can we convert below statement to angular`s renderer2 ?
this.elementRef.nativeElement.style.setProperty( '--primary-color ' , '#455363' )
Run Code Online (Sandbox Code Playgroud)
Above statement is changing css-variable into the directive when dark mode is selected. As in angular it is not good practice to access DOM directly, thats why we uses renderer2. But i do not know how to convert above statement to renderer2 for safely access DOM.
At very simple, can anyone tell me how to safely change css-varible in …