这是我的控制器
$scope.subjects = ["Computer Security", "Graphics and Multimedia", "Networks", "Computer Science and Engineering", "Game Design", "Programming", "Information Technology", "Software Engineering", "Technology Management", "Telecommunications", "Web Development", "Sociology", "Psychology", "General", "Social Work", "Criminal Justice", "Law and Paralegal", "Public Safety", "Forensic Sciences", "Counseling", "Homeland Security", "Political Science", "Public Administration"];这是我的观点,我在这里绑定数据。
<label class="concentration-label3" ng-repeat="value in subjects">
<input ng-model="value.selected" ng-disabled="subjectCheckedCount == subjectLimit && !value.selected" type="checkbox" name="concentrations" class="concentration-label3__input js-concentration-value" value="{{value}}" data-mixpanel-subject="Design" >
<span class="concentration-label3__title" for="conc1">
{{value}}
<span class="concentration-label3__title__checkmark4"></span>
</span>
</label>它给我的错误‘不能绑定属性选择字符串xyz’请帮助!
发布于 2016-09-11 15:31:22
subjects是一个字符串数组,它没有试图绑定到输入的属性selected。
发布于 2016-09-11 16:01:49
for(var j = 0; j < $scope.subjects.length; j++){
$scope.subjectsArray.push({
'name': $scope.subjects[j],
'value': $scope.subjects[j]
});
}我们必须提供ng-重复一个对象,以便以后创建该对象的任何属性。我们不能创建字符串的属性。因此,我将字符串数组转换为对象数组。
https://stackoverflow.com/questions/39437597
复制相似问题