2017-09-07 10 views
0

내가 가진 입력 : 나는에 회사를 두 번 클릭 할 때 나는 "새로운"버튼을 클릭하거나, 경우 : 2 차례에 걸쳐 열립니다입력 참/거짓 진술에 [장애인] - 각도 2

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

그리고 팝업 모달 그리드를 사용하여 해당 회사의 속성을 편집 할 수 있습니다.

내 입력은이 요소의 시작 부분에서 가져온 CompanyTemplatePopupComponent에 있습니다. 입력에 영향을 주려면 일부 경로를 지정해야하는 경우가 있습니다.

는 내가 원하는 내가 editCompany에 대한 열 때, 그런 식으로 this.modal.open 기능에 작성하는 것입니다 - 입력 비활성화되고 newCompany가 활성화 될 때, 입력 필드도 사용할 수 있습니다. 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]="disableInput?'':null" 

이 있는지 확인은의 [attr.disabled]은 null로 설정해야합니다 브라우저에서 렌더링 될 때.