민자의 지식창고

FormGroup안에서 Input 필드 disabled 동적 활성화 본문

개발노트/Angular

FormGroup안에서 Input 필드 disabled 동적 활성화

전지적민자시점 2020. 10. 19. 16:55

FormGroup에서 Input 필드를 동적으로, Disabled 속성을 주고 싶음

작업 하려는 내용은 아래와 같습니다. formgroup안의 select를 변경시킬때 마다, Input의 Disabled 속성이 바뀐다

    아래를 찾아보면서 몇가지 확인 한 사항들 입니다
  • FormcontorlName과 FormControl의 차이점
  • select의 change 값에 대한 selectionChange 함수
  • form의 get과 set의 활용

formgroup을 이용한 get,set을 하면, 해당 필드의 값을 받아 올수가 있습니다. 먼저 필드에 fromcontorlName 지정어에 있는 값을 this.upaForm.get('upa_number')으로 불러오면 해당 값을 control이 가능 합니다.
Form 전체를 contorl 하여, disable 하려면 this.form.disable()과 같이 사용 합니다.
부분적 contorl를 하려면, 부여된 지정어를 호출하여, 속성을 지정 합니다.this.form.get('first').disable() 과 this.form.get('first').enable() 특히, 중요한 점은 ngmodel과 중첩헤서 사용하면 안됩니다.

[FormGroup]은 직접 선언해야 하지만, FormControlName은 Formgoupr과 함께 사용하며, 여러 필드를 한꺼번에 저장을 시킵니다.

 

https://stackoverflow.com/questions/40171914/what-is-the-difference-between-formcontrolname-and-formcontrol

 

What is the difference between formControlName and FormControl?

I'm using ReactiveFormsModule of Angular2 to create a component that contains a form. Here is my code: foo.component.ts: constructor(fb: FormBuilder) { this.myForm = fb.group({ 'fulln...

stackoverflow.com

 

728x90

'개발노트 > Angular' 카테고리의 다른 글

Angular Lifecycle  (0) 2021.10.06
Angular Unit test  (0) 2020.09.11
Angular의 Observable  (1) 2020.08.26
Angular Coding style Guide  (0) 2020.08.25
Element  (0) 2020.08.25