标签: angularjs concatenation angular-ngmodel
如何将字符串与范围变量连接并将其分配给ng-model
有没有办法表达这个
ng-model="'is'+location.placeName+'Checked'"
答案 0 :(得分:0)
在这种情况下,您可以使用ng-bind-model而不是ng-model
ng-bind-model="is{{location.placeName}}Checked"
感谢
答案 1 :(得分:0)
最后plunker使用ng-init
ng-init
HTML视图
<input ng-model="isPlaceChecked" ng-init="isPlaceChecked = checkIfPlaceChecked(location.placeName)"
JS控制器
$scope.checkIfPlaceChecked = function (placeName) { return "is" + placeName + "Checked"; }