NgFormModel - 绑定已有控件组 的练习

0

constructor()内需要怎么写,才能把值显示在入力框内

  • 0
    shiney 88个月前 回答

    可是使用NgControlGroup分组后,输入框里的值就不显示了?

     template:`

    <div>

    <ul [ngFormModel]="controls">

    <li>姓名:<input type="text" ngControl="name"></li>

                </ul>

                <ul [ngControlGroup]="contact">

    <li>地址:<input type="text" ngControl="address"></li>

    <li>电话:<input type="text" ngControl="telephone"></li>

    </ul>

    </div>

    <pre>{{dump()}}</pre>

    `


    constructor(){

    this.controls = new ControlGroup({

    name : new Control("Jason"),

    contact: new ControlGroup({

                  address : new Control("London U.K."),

                  telephone : new Control("114")

          })

    });

    }

  • 1
    ciga 88个月前 回答
    入力框是指输入框吗?如果是的话,你在constructor中创建Control对象的时候,指定的值就是输入框的初始值。