所以我只想要一个默认选中的单选按钮(在这种情况下,我希望默认选择“否”)。这是我尝试过的所有方法...
表单组优先
<div class="form-group">
<div ng-app>
<div ng-init="externalClientNo">
<label class="control-label" for="approvalrequired">Will be used for External Client:</label>
<span class="help-tip">
<p>Select Yes or No</p>
</span>
<div class="form-inline">
<div class="radio">
<input type="radio" id="externalClientYes" class="form-control" ng-model="externalClientYes" formControlName="approvalrequired" value="Y" (click)="Ext('Y')"/>
<label for="externalClientYes">Yes</label>
</div>
<div class="radio">
<input type="radio" id="externalClientNo" ng-model="externalClientNo" class="form-control" formControlName="approvalrequired" value="N" (click)="Ext('N')"/>
<label for="externalClientNo">No</label>
</div>
</div>
</div>
</div>
</div>
NG-APP FIRST
<div ng-app>
<div ng-init="externalClientNo">
<div class="form-group">
<label class="control-label" for="approvalrequired">Will be used for External Client:</label>
<span class="help-tip">
<p>Select Yes or No</p>
</span>
<div class="form-inline">
<div class="radio">
<input type="radio" id="externalClientYes" class="form-control" ng-model="externalClientYes" formControlName="approvalrequired" value="Y" (click)="Ext('Y')"/>
<label for="externalClientYes">Yes</label>
</div>
<div class="radio">
<input type="radio" id="externalClientNo" ng-model="externalClientNo" class="form-control" formControlName="approvalrequired" value="N" (click)="Ext('N')"/>
<label for="externalClientNo">No</label>
</div>
</div>
</div>
</div>
</div>
已检查
<input type="radio" id="externalClientNo" ng-model="externalClientNo" class="form-control" formControlName="approvalrequired" value="N" (click)="Ext('N') checked"/>
<label for="externalClientNo">No</label>
AND
<input type="radio" id="externalClientNo" ng-model="externalClientNo" class="form-control" formControlName="approvalrequired" value="N" (click)="Ext('N')" checked="checked"/>
<label for="externalClientNo">No</label>
我明白了为什么选中的方法可能不起作用,但第一种方法应该起作用。我已经看到了演示的工作原理,这就是文档所说的实现方式。我想念什么吗?
谢谢!