Skip to content Skip to sidebar Skip to footer

Cannot Create Property 'selected' On String 'information Technology' Angularjs

This is my controller $scope.subjects = ['Computer Security', 'Graphics and Multimedia', 'Networks', 'Computer Science and Engineering', 'Game Design', 'Programming', 'Informati

Solution 1:

subjects is an array of strings, which don't have the property selected that you're trying to bind to your input.

Solution 2:

for(var j = 0; j < $scope.subjects.length; j++){
    $scope.subjectsArray.push({
        'name':  $scope.subjects[j],
        'value': $scope.subjects[j]
    });   
}

We must provide ng-repeat an object in order to create any property of that object later. We cannot create a property of a string. So I converted my array of string into array of objects.

Post a Comment for "Cannot Create Property 'selected' On String 'information Technology' Angularjs"