AngularJS遇到了问题:
错误:[$ parse:syntax] http://errors.angularjs.org/1.3.7/ $解析/语法P0 =%7B&安培; P1 =无效%20key&安培; P2 = 2及P3 =%7B%7Bcampaign.paused%7D%7D&安培; P4 =%7Bcampaign.paused%7D%7D 在错误(本机) 在http://localhost/platform/js/angular/angular.min.js:6:416 at gb.throwError(http://localhost/platform/js/angular/angular.min.js:190:254) 在gb.object(http://localhost/platform/js/angular/angular.min.js:199:435) 在gb.primary(http://localhost/platform/js/angular/angular.min.js:189:308) 在gb.unary(http://localhost/platform/js/angular/angular.min.js:197:82) at gb.multiplicative(http://localhost/platform/js/angular/angular.min.js:196:324) 在gb.additive(http://localhost/platform/js/angular/angular.min.js:196:182) 在gb.relational(http://localhost/platform/js/angular/angular.min.js:196:48) at gb.equality(http://localhost/platform/js/angular/angular.min.js:195:418)(anonymous 函数)@ angular.js:11592b。$ get @ angular.js:8542c。$ get.l. $ digest @ angular.js:14241c。$ get.l. $ apply @ angular.js:14486l @ angular.js:9644O @ angular.js:9834w.onload @ angular.js:9775
原点很明显,当我删除这个HTML时它会消失
<input type="checkbox" ng-model={{campaign.paused}}
ng-true-value="'1'" ng-false-value="'0'" />
$ scope.campaign.paused来自我从服务器收到的JSON数据:
{
"campaign_id": "1",
"paused": "0"
}
问题:如何让我的HTML将paused
中的0或1识别为真/假,并(un)相应地选中该框?
答案 0 :(得分:1)
将ng-checked指令与复选框一起使用。
<input type="checkbox" ng-checked={{campaign.paused}} />
答案 1 :(得分:1)
尝试删除模型中的花括号:
<input type="checkbox" ng-model="campaign.paused" ng-true-value="1" ng-false-value="0" />