【发布时间】:2016-09-19 17:55:20
【问题描述】:
我正在尝试读取单选按钮的值 - 角度为 2,
index.html
<input type="radio" id="options1" name="function" value="create">
<input type="radio" id="options2" name="function" value="continue">
index.ts
@Component({
selector: 'function',
templateUrl: './client/components/function/index.html',
styleUrls: ['./client/components/function/index.css'],
providers: [],
directives: [ROUTER_DIRECTIVES]
})
我需要根据单选按钮值是创建还是继续在 html 中显示一个 div。
我尝试过的:
- 使用
document.getElementById获取打字稿文件中单选按钮的值 - 未检测到属性checked。 - 通过在打字稿中定义
model来使用model.function读取值。显然无法访问model变量! - 尝试使用
[(ngModel)]- 也没有用。
请为此提出周转建议。
【问题讨论】:
标签: javascript html templates angular