2017-07-21 63 views
0

我有一个数据表。当我点击表的行时,会发送Http调用的id,并且模式将与数据一起打开。但是模式没有获取数据。我有回应,但我认为模态在响应之前呈现。如何在点击时将数据显示到模式中?HTTP之前的模式加载获取请求角度2

模板:

Table : 
<div class="table-responsive"> 
     <div class="table table-striped"> 
     <table class="table table-striped" id="emp_address_list"> 
      <thead> 
      <tr class="sub-header"> 
       <th> 
       Address 
       </th> 
       <th>Type</th> 
       <th width="15%">Status</th> 
      </tr> 
      </thead> 

      <tbody id="address-list" *ngIf="addressData == null"><tr><td colspan="4" align="center">No Active Records Found.</td></tr></tbody> 

      <tbody id="address-list" *ngIf="addressData"> 
       <tr *ngFor="let full of addressData " class="{{full.status}}style show-{{full.status}}" data-target="#address-details-modal" data-toggle = "modal" (click)="seperateId(full.ID)"> 
       <td class="{{full.status}}style show-{{full.status}}" > 
        {{full.address1}} {{full.address2}} 
       </td> 
       <td class="{{full.status}}style show-{{full.status}}"> 
        {{full.type}} 
       </td> 
       <td class="{{full.status}}style show-{{full.status}}"> 
        {{full.status}} 
       </td> 
       </tr> 
      </tbody> 

     </table>  
     </div> 

模式:

<div class="modal fade" id="myModal" role="dialog"> 
     <div class="modal-dialog"> 

      <!-- Modal content--> 
      <div class="modal-content"> 
      <div class="modal-header"> 
       <button type="button" class="close" data-dismiss="modal">&times;</button> 
       <h4 class="modal-title">Modal Header</h4> 
      </div> 
      <div class="modal-body"> 
       <div class="col-md-9 col-sm-9 col-xs-9 emp-panel-group current-row emp-tab-bottom-margin" id="address_div" > 
    <dl class="dl-horizontal" *ngIF="addressid" >    
     <dt>Address:</dt><dd> {{addressid.address1}} </dd> 
     <dt>Type:</dt><dd>{{addressid.type}}</dd> 
     <dt>Notes:</dt><dd>{{addressid.notes}}</dd> 

     <dt>Created On:</dt><dd></dd>    
    </dl> 

    </div> 
      </div> 
      <div class="modal-footer"> 
       <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
      </div> 
      </div> 

     </div> 
     </div> 

HTTP调用:

seperateData(id) { 
       const eurl='http://localhost/Angular/AddressSeperate.php?id=' 
       const url= `${eurl}${id}` 
       return this.http.get(url) 
       .map(this.extractData) 
       .catch(this.HandleError) 
      } 
+0

http呼叫在哪里? – Meir

+0

https://github.com/shlomiassaf/angular2-modal http://plnkr.co/edit/ZAZqZu?p=preview https://github.com/shlomiassaf/angular2-modal/tree/master/src/demo – JGFMK

+0

我收到回复,但打开时数据没有进入模式。我在点击表格行时发送一个HTTP调用。如果数据存在,我保留数据以呈现数据。我正在从服务器获取响应,但数据未呈现。我认为Modal即使在服务响应之前也会开放。在这种情况下我该怎么办?请帮我解决一下这个。 – Prakash

回答

0

在模板的模式,看看这个行:

<dl class="dl-horizontal" *ngIF="addressid" > 

更换外壳*ngIf

+0

我改变了。情况并非如此。 – Prakash