引导模式显示Angular 6组件中的缓存数据

时间:2018-09-06 09:26:39

标签: angular twitter-bootstrap redux-observable

ngOnInit() {
    this.subscription = this.allDataModelService.getStats().subscribe(data => 
    this.modalStatsArrayObj = data;
    this.storyId = this.modalStatsArrayObj[0].story;
    $('#storyStatsModal').modal('show');

这是HTML

<div class="modal fade" id="storyStatsModal" role="dialog" tabindex="-1" *ngIf="modalStatsArrayObj">
   <div class="modal-dialog" style="margin-top:250px; width:500px">
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h2 class="modal-title" style = "text-align:center"><b>{{storyId}}</b></h2>
        </div>
        <div class="modal-body" style = "margin-left:20px;">
           <div *ngFor="let item of modalStatsArrayObj" class="row" style="margin-top:10px">
          <div class="col-md-5" >
             <span class="modal-stats-heading" style="float:left;">{{item.key}}</span>
        </div>
        <div class="col-md-5" >
        <span class="modal-stats" style="float:left;">{{item.value}}</span>
      </div>
    </div>
    <div class="row">
      <div class="col-lg-12" style="margin-top:20px;">
        <span class="side-note">Note: All the fields are in days unit</span>
      </div>
    </div>
  </div>
</div>

我正在从服务获取数据并将其与Modal HTML绑定。模态每次都会显示缓存的数据。我试图清除“ hidden.bs.modal”事件上的所有模型对象,并在调用服务时重新填充它们。

0 个答案:

没有答案