我在表的标题中显示数组键,并且键中有下划线。我想用HTML表格中的空格替换下划线。我不想在组件中这样做,因为我还有其他要求。
<table>
<thead>
<tr>
<th *ngFor="let header of printFields">{{header}}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let ab of printData">
<td *ngIf="ab.Bill_Number">{{ab.Bill_Number}}</td>
<td>.....</td>
<td>.....</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud) 无法打印字段值.引发"无法读取属性'推送'未定义"错误
我的component.html
<div class="checkbox abc-checkbox abc-checkbox-success">
<input class="inputChk" value="Serial_Number" id="ser_num" type="checkbox" checked="true">
<label for="Serial_Number">Serial Number</label>
</div>
<div class="checkbox abc-checkbox abc-checkbox-success">
<input class="inputChk" value="Stock_Number" id="stk_num" type="checkbox" checked="true">
<label for="Stock_Number">Customer Stock Number</label>
</div>
<button type="button" class="btn btn-primary" (click)="submitCheckedValues()">Submit</button>
Run Code Online (Sandbox Code Playgroud)
我的组件
export class Sample{
fields: String[] = [];
submitCheckedValues(){
$('input:checkbox.inputChk').each(function () {
var sThisVal = (this.checked ? $(this).val() : "");
//printing sThisVal;
if(sThisVal){
this.fields.push(sThisVal);
}
});
console.log(this.fields);
}
Run Code Online (Sandbox Code Playgroud)