[英]Angular tag inside html element
I have the following angular code: 我有以下角度代码:
<div ng-repeat="creation in creations">
<input type="checkbox" data-foobar="[[creation.foobar]]" [[creation.params]]>
[[creation.params]]
</div>
That's it, the problem is that creation.params
contains "disabled checked" or "checked" values, and it should create disabled checkboxes, but it does not. 就是这样,问题是creation.params
包含“ disabled checked”或“ checked”值,它应该创建禁用的复选框,但事实并非如此。 I don't know why, all checkboxes are unchecked. 我不知道为什么,所有复选框都未选中。
Even though when I later display creation.params
variable, it shows correct value: 即使稍后显示creation.params
变量时,它也会显示正确的值:
disabled checked
disabled checked
disabled checked
checked
disabled checked
for 5 checkboxes - but all are unchecked. 5个复选框-但未选中所有复选框。
What's wrong? 怎么了?
By the way, I have used: 顺便说一句,我用过:
$interpolateProvider.startSymbol('[[').endSymbol(']]');
Easiest way to do that would be using ngChecked . 最简单的方法是使用ngChecked 。
If yo uwant to have more control check official documentation and model your problem as described, it will work. 如果您想拥有更多控制权,请检查官方文档并按照说明对问题进行建模,这将起作用。 Use ng-model
together with ng-true-value
and ng-false-value
. 将ng-model
与ng-true-value
和ng-false-value
。
Edit: 编辑:
function isChecked(param) {
return param === 'checked';
}
or directly in template: 或直接在模板中:
ng-checked="creation.params === 'checked'"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.