如何在角度2中调用HTTP方法后更新Dom属性?

时间:2017-02-15 10:51:14

标签: angular

我正在使用棱角2.4.6 ..

我的ts文件是

book_data(){
    this.after_book_data=true
let empid = this._cookieservice.get('EmployeeID')
        const body = new Category(empid)

        const headers = new Headers({ 'Content-Type': 'application/json' });
        return this.http.post(this.url + '/FindallBooks', body, { headers: headers })
            .subscribe(
            data => {
                //////////console.log("entering")
                if (data.json().success) {

                     this.BOOKDATA = (data.json().extras.BOOKDATA)



                }
                else {
                    const msgNumber: number = parseInt(data.json().extras.msg);
                    let message = this._ApiMessageService.ApiMessages[msgNumber]
                    this.ErrorService.handleError(message)
                }

            })
}

我的HTML是:

<div class="col-md-4 col-md-offset-2" style="background-color: #fff">
            <table class="table table-striped table-shadow" *ngIf="BOOKDATA.length">
            <tr>
                <th>Book S.No.</th>
                <th>Book Name</th>
            </tr>
            <tr *ngFor="let new of BOOKDATA">
                <td>{{ new.BookName }}</td>
            <td>{{ new.ISBN_Number }}</td>
            </tr>
        </table>
        </div>

<form class="form-signin form-horizontal" (ngSubmit)="onSubmit(ff)" #ff="ngForm">

当我提交我调用book_data()方法时,我也得到了更新的json数据。但是我的bookdata表没有更新。我试过更改了导入器

0 个答案:

没有答案