我在gridview中显示mysql数据时遇到问题。我使用Angular 4来绑定数据并在gridview中显示。 我可以绑定网格,但数据不会显示在网格中,控制台也没有错误。即使我在控制台得到回应。
这是我对gridview的html代码:
<sa-widgets-grid>
<!-- row -->
<div class="row">
<!-- NEW WIDGET START -->
<article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<!-- Widget ID (each widget will need unique ID)-->
<sa-widget>
<!-- widget options:
usage: <sa-widget id="wid-id-0" [editbutton]="false">
[colorbutton]="false"
[editbutton]="false"
[togglebutton]="false"
[deletebutton]="false"
[fullscreenbutton]="false"
[custombutton]="false"
[collapsed]="true"
[sortable]="false"
-->
<header>
<span class="widget-icon"></span>
<h2>Add Broadcaster </h2>
<div class="widget-toolbar">
<!--<button class="btn"><span class=""><i class="fa fa-plus-square"></i> </span><span>Import</span></button>-->
<button class="btn"><span class=""><i class="fa fa-plus-square"></i> </span><span>Add New</span></button>
</div>
</header>
<!-- widget div-->
<div>
<!-- widget content -->
<div class="widget-body">
<!-- this is what the user will see -->
<div class="widget-body no-padding">
<sa-datatable [options]="{
data: broacasterall,
columns: [
{data:'id'},
{data:'broadcaster_name'},
{data:'broadcaster_channel_name'},
{data:'broadcaster_email'},
{data:'w_application_name'},
{data:'state_code'}
],
buttons: [
'colvis'
]
}" tableClass="table table-striped table-bordered table-hover">
<thead>
<tr>
<th data-class="expand">Id</th>
<th data-class="expand">Broadcaster Name</th>
<th data-class="expand">Channel Name</th>
<th data-class="expand">Category Name</th>
<th data-class="expand">Email</th>
<th data-class="expand">Application Name</th>
<th data-class="expand">State,City</th>
<th data-class="expand">Video URL</th>
<!-- <th data-class="expand">YouTube Key</th>
<th data-class="expand">FaceBook Key</th>
<th data-class="expand">Haappyapp Key</th> -->
</tr>
</thead>
</sa-datatable>
</div>
</div>
<!-- end widget content -->
</div>
<!-- end widget div -->
</sa-widget>
这是我的component.ts文件:
在此代码中,我调用广播公司的响应,并在控制台中获得响应。
这里也没有问题。当我调试代码时,我在网格中完美地获取数据,但是在localhost中它没有绑定。
getBroadcasterAllGrid()
{
this.broadcasterService.getAllBroadcasters()
.subscribe(
broadcasterResponse=>{
this.broacasterall=broadcasterResponse;
}),
error => this.errorMessage = <any>error;
};