2017-09-07 5 views
0

私が持っている入力:私は会社をダブルクリックしたときに、私は、「新規」ボタンをクリック、またはとき:2回開き入力真/偽ステートメントの[無効] - 角度2

<input class="form-control" type="text" [(ngModel)]="context.company.city.zipCode"> 

、ポップアップモーダルグリッドを使用してその会社のプロパティを編集します。

私の入力は、入力に影響を及ぼすためにいくつかのパスを指示する必要がある場合に、このコンポーネントの先頭にインポートされるCompanyTemplatePopupComponentにあります。入力が無効になっている、とnewCompanyが活性化すると、入力フィールドも有効になっている - 私が欲しいもの

は私がeditCompanyのために開いたときにすることを、そのようにthis.modal.open機能に書くことです。 isUpdateは、それが何らかの形で役立つ場合は既にブール値です。

openCompanyPopup(isUpdate, company) { 

    let companyToEdit = isUpdate ? company : this.companyTemplate; 

    this.modal.open(CompanyTemplatePopupComponent, overlayConfigFactory({ 
     dialogClass: 'modal-dialog style-dialog', 
     company: companyToEdit, 
     isUpdate: isUpdate, 
     countries: this.countries, 
    }, BSModalContext)) 
     .then((d: any) => d.result) 
     .then(result => { 

      if (isUpdate) { 

       this.companyService.editCompany(result) 
        .subscribe(company => { 
         this.companyService.get().subscribe(response => this.handleSuccess(response)); 
        }); 
      } 
      else { 

       this.companyService.newCompany(result) 
        .subscribe(company => { 
         this.companyService.get().subscribe(response => this.handleSuccess(response)); 
        }); 
      } 
     }); 
} 

答えて

1

変数を追加できます。ブールタイプのdisableInputCompanyTemplatePopupComponentにあるとします。

上記の変数は、モーダルオープン後に呼び出すことができる関数で設定できます。変数がfalseに設定されている場合起因無効をHTMLから削除されるように、[attr.disabled]は、nullに設定する必要があることを確認してください

[attr.disabled]="disableInput?'':null" 

入力を無効または有効にする

使用このブール変数をブラウザでレンダリングされたときに発生します。

関連する問題