我用angular2使用jQuery,我創建了一個數據表,當我使用靜態數據都好,但只要我做一個循環* ngFor沒有什麼作品(過濾,分頁,搜索)Angular 2,jQuery,* ngFor不工作?
component.html
<table id="dtb" class="table table-striped table-no-bordered table-hover" cellspacing="0" width="100%"
style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Date</th>
<th class="disabled-sorting text-right">Actions</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th class="text-right">Actions</th>
</tr>
</tfoot>
<tbody>
<tr *ngFor="let data of datas">
<td>{{data.Name}}</td>
<td>{{data.Position}}</td>
<td>{{data.Office}}</td>
<td>{{data.Age}}</td>
<td>{{data.Date}}</td>
<td class="text-right">
<a href="#" class="btn btn-simple btn-info btn-icon like"><i class="material-icons">favorite</i></a>
<a href="#" class="btn btn-simple btn-warning btn-icon edit"><i class="material-icons">dvr</i></a>
<a href="#" class="btn btn-simple btn-danger btn-icon remove"><i class="material-icons">close</i></a>
</td>
</tr>
</tbody>
</table>
compoent.ts
import {Component, OnInit, ElementRef} from '@angular/core';
import {TableData} from './table-data';
declare var $:any;
@Component({
templateUrl: 'Home.component.html'
})
export class HomeComponent implements OnInit {
datas: Array<any> = TableData;
constructor(private _elRef: ElementRef) {}
ngOnInit() {
jQuery(this._elRef.nativeElement).find('#dtb').DataTable();
}
}
一些幫助?謝謝所有
Angular與其他人玩不好。 –