我有有另一個2內的表單控件年月表單控件loanTerm內部控制形式,我想通過重置在角2
this.form.control['years'].reset();
重置它不幸的是它不工作,因爲當我訪問this.form.control的屬性唯一可用的對象是loanTerm。
<df-years-months-question ng-reflect-_model="[object Object]" ng-reflect-minimum-period="48" ng-reflect-maximum-period="474" ng-reflect-question-label="Loan term" ng-reflect-name="loanTerm" id="loanTerm" class="ng-untouched ng-pristine ng-invalid"><div class="form-inline ng-untouched ng-pristine ng-valid" ng-reflect-form="[object Object]">
<!--bindings={
"ng-reflect-ng-if": "false"
}-->
<div class="input-group col-xs-5 col-sm-3">
<input class="form-control ng-untouched ng-pristine ng-valid" formcontrolname="years" type="number" ng-reflect-name="years" min="48" max="474">
<span class="input-group-addon">years</span>
<div class="input-group col-xs-5 col-sm-3">
<input class="form-control ng-untouched ng-pristine ng-valid" formcontrolname="months" max="11" min="0" type="number" ng-reflect-name="months">
<span class="input-group-addon">months</span>
</div>
</div>
</df-years-months-question>
</div>
我已經試過如下:不幸的是沒有工作
this.form.control['loanTerm'].reset();
this.form.get('loanTerm').get('years').reset();
模型價值,你可以發佈你的HTML,而不是編譯一個? – galvan
你有一個** formgroup **'loanTerm',而不是**表單控件**對嗎?你想達到什麼目標有點不清楚。什麼應該重置?你也可以顯示實際的代碼,TS和模板:) – Alex