【问题标题】:How to turn-on a radio button programmatically如何以编程方式打开单选按钮
【发布时间】:2021-12-19 08:05:01
【问题描述】:

我有下面发布的单选按钮和输入。我想以编程方式切换单选按钮,这样,当我将 this.iAreaOfCoverageForThresholdPasser.average-height 设置为 true 时,单选按钮应该打开“突出显示”。

HTML

<div id="idRadioButtonForAverageHeightDivision">
  <input [value]="1" [(ngModel)]="iOperationPasser.averageHeight" name="radioGroupForOperations" type="radio" clrCheckbox  (change)="onAverageHeightOptionSelected($event)"  [(checked)]="averageHeight"/>
  <label id="operation-average-height">
    {{ "SITE.AREAS_OF_COVERAGE_FOR_THRESHOLD.OPERATION_AVERAGE_HEIGHT" | translate }} 
    <button class="btn btn-sm btn-icon" (click)="showInformation('SERVICE_DIST_4_AGRI')">
       <clr-icon shape="help-info" class="is-solid"></clr-icon>
    </button>
  </label>
</div>

【问题讨论】:

  • average-height 不是有效标识符。
  • @Dai 你能告诉我为什么吗?我没有收到与此问题相关的任何错误

标签: javascript html angular typescript


【解决方案1】:

.html:

<div id="idRadioButtonForAverageHeightDivision">
 <input [value]="1"
        name="radioGroupForOperations"
        type="radio" 
        clrCheckbox
        (change)="onAverageHeightOptionSelected($event)"  
        [(checked)]="iOperationPasser.averageHeight"
 />

 <label id="operation-average-height">
 <button class="btn btn-sm btn-icon" (click)="onClick()">
  press
 </button>
 </label>
</div>

.ts

iOperationPasser = {
 averageHeight: true
}

onClick = () => {


this.iOperationPasser.averageHeight=!this.iOperationPasser.averageHeight;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-09
    • 1970-01-01
    • 1970-01-01
    • 2021-12-18
    • 1970-01-01
    • 2014-06-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多