purplewind
purplewind

Reputation: 351

Errors using ng-repeat to display data in view AngularJS

I am trying to display some data from an array in the view using ng-repeat but it does not work.

This is how my html looks:

<div>
        <p>loop here</p>
        <ul>
            <li ng-repeat="item in transferTest">{{item.Marks}}</li>
            <li>{{item}}</li>
            <li>{{item.Marks}}</li>
        </ul>
    </div>

And this is how my controller looks:

 $scope.resultsArray.push({"Module_Code": $scope.moduleCode, "Marks" :$scope.marks,"Recommendation" :$scope.moduleRecommendation})                                       
  $rootScope.transferTest = $scope.resultsArray;

Basically this is how my data is organized:

[
{"Module_Code": "IT", "Marks": "70", "Recommendation": "test"}
{"Module_Code": "ACC", "Marks": "30","Recommendation": "testintuber"}

It seems that I am unable to access the $rootScope.transferTest from the view.

Upvotes: 0

Views: 54

Answers (2)

Sajeetharan
Sajeetharan

Reputation: 222582

Your JSON is not properly formated,

it should be,

[
{"Module_Code": "IT", "Marks": "70", "Recommendation": "test"},
{"Module_Code": "ACC", "Marks": "30","Recommendation": "testintuber"}]

DEMO

Upvotes: 1

Mikkel
Mikkel

Reputation: 7777

Your data is malformed: [ {"Module_Code"= "IT", "Marks": "70", "Recommendation": "test"} {"Module_Code**:= "ACC", "Marks:** "30","Recommendation:= "testintuber

Upvotes: 1

Related Questions