How to make a formControl readonly

后端 未结 6 540
死守一世寂寞
死守一世寂寞 2020-12-15 03:24

How to make a formControl in angular readonly

I know i can do it in html like


         


        
6条回答
  •  悲哀的现实
    2020-12-15 03:50

    A simple solution is to set the formcontrol as not disabled:

    this._formBuilder.group({
                some: new FormControl(
                  {
                    value: parseInt(this.myobject.subObject.stringMember),
                    disabled: false
                  },
                  Validators.required
                ),
    

    and, at the same time, to set the and/or

    • input:
    
    

    this works with input and textarea at least.

提交回复
热议问题