角度ng如果未显示在组件中变为true的div

时间:2018-08-27 11:20:37

标签: angular

这是我的Component类,我在其中切换saveSuccessnotification,saveSuccessnotification变为true,但在html中,未呈现div的显示为enter image description here

在图像中,我的绑定数组为空,但在component中,它是正确的,因此可以在component中按预期工作

 export class commandBarComponent implements OnInit {
  public saveSuccessnotification: boolean;
  public saveErrornotification: boolean;
  saveOutputData(): void {
    this.saveSuccessnotification = false;
    this.saveErrornotification = false;
    clearTimeout(this.succestimeout);
    this.isSaveLoader = true;
    let appService = this.appservice;
    let local = this;
    local.saveData.elementDTOs[0].ElementTitle = local.saveData.elementDTOs[0].ElementTypeId == 8 ? local.saveData.elementDTOs[0].Data.ScenarioTitle : local.saveData.elementDTOs[0].Data.Title ? local.saveData.elementDTOs[0].Data.Title:null;
    local.saveData.elementDTOs[0].ElementDescription = local.saveData.elementDTOs[0].Data.Description;
    local.saveData.elementDTOs[0].DisplayTitle = local.saveData.elementDTOs[0].Data.DisplayTitle;
    appService.getDTStudioV2CompServiceToken().subscribe(token => {
      local.saveData.apiAuthToken = token;
      if (local.saveData.Id === 0) {
        local.saveData.ItemTypeId = 0;
      }
      if (local.saveData.elementDTOs[0].Id !== 0 && local.saveData.elementDTOs[0].Id !== null && local.saveData.elementDTOs[0].Id !== '') {
        local.saveData.elementDTOs[0].MetaData.ModifiedBy = local.userName;
        local.saveData.elementDTOs[0].MetaData.ModifiedByEmail = local.userEmail;
        local.saveData.elementDTOs[0].MetaData.ModifiedById = local.userGUID;
        local.saveData.Id = 0
        local.saveData.ItemTypeId = 0;
      }
      if (local.saveData.elementDTOs[0].ElementTypeId == 8) {
        if (local.saveData.Id === 0) {
          if (Array.isArray(local.saveData.elementDTOs[0].Pivot.Scenarios)) {
            local.saveData.elementDTOs[0].Pivot.Scenarios.push({ "ScenarioName": local.saveData.elementDTOs[0].ElementTypeId == 8 ? local.saveData.elementDTOs[0].Data.ScenarioTitle : local.saveData.elementDTOs[0].ElementTitle })
          } else {
            local.saveData.elementDTOs[0].Pivot.Scenarios = [];
            local.saveData.elementDTOs[0].Pivot.Scenarios.push({ "ScenarioName": local.saveData.elementDTOs[0].ElementTypeId == 8 ? local.saveData.elementDTOs[0].Data.ScenarioTitle : local.saveData.elementDTOs[0].ElementTitle });
          }
          appService.postServiceData(local.saveData).subscribe(data => {
            this.isSaveLoader = false;
            if (data && data.Result != null) {
              this.saveSuccessnotification = true;
              this.succestimeout = setTimeout(() => {
                this.saveSuccessnotification = false;
              }, 50000);
            }
            else {
              this.saveErrornotification = true;
            }
            local.params = data;
            local.saveEvent.emit(local.params);
          });
        } 
      }     
    });
  }
 }
 
 
 
<div class="notification-panel __success" *ngIf="saveSuccessnotification">
  <div class="notification-mesg">
    <p>Details saved successfully.</p>
    <button class="ms-Icon ms-Icon--ChromeClose"  (click)="saveSuccessnotification = false; clearTimeout(succestimeout);"></button>
  </div>
</div>

0 个答案:

没有答案