我试图根据我从后端系统获得的值有条件地将一个类分配给div.
说有物体'A'具有可变status,其可能具有的值status1和status2.
我正在尝试使用Angular 2根据状态有条件地分配2个类(class1和class2).以下是我正在使用的条件.请为此建议一个替代方案,
<div ng-class="{status1 : 'class1', status2 : 'class2'}[A.status]">
...
</div>
Run Code Online (Sandbox Code Playgroud) 我正在尝试读取单选按钮值 - 以角度2,
的index.html
<input type="radio" id="options1" name="function" value="create">
<input type="radio" id="options2" name="function" value="continue">
Run Code Online (Sandbox Code Playgroud)
index.ts
@Component({
selector: 'function',
templateUrl: './client/components/function/index.html',
styleUrls: ['./client/components/function/index.css'],
providers: [],
directives: [ROUTER_DIRECTIVES]
})
Run Code Online (Sandbox Code Playgroud)
我需要根据是否创建或继续单选按钮值在html中显示div.
我尝试过的:
document.getElementById- checked未检测到属性获取打字稿文件中单选按钮的值.model.function通过model在打字稿中定义a 来读取值.model显然,无法访问变量![(ngModel)]- 也没用.请为此建议一个转机.