Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AngularJS An Introduction to Two-Way Data Binding Lists

rigoberto contreras
rigoberto contreras
9,035 Points

can some one spot the problem

been trying for a while any hints

index.html
<!DOCTYPE html>
<html ng-app="myApp">
<head>
  <title>Angular.js</title>
  <script src="js/angular.js"></script>
  <script src="app.js"></script>
</head>
<body ng-controller="myController">
  <ul>
<li ng-repeat="name in bowlOfFruit" ng-list>
  {{name.bowlOfFruit}}

    </li>
    <li ng-repeat="name in bowlOfFruit" ng-list>
  {{name.bowlOfFruit}}
    </li>
<li ng-repeat="name in bowlOfFruit" ng-list>
  {{name.bowlOfFruit}}
    </li>


  </ul>
</body>
</html>
app.js
angular.module('myApp', [])
.controller('myController', function ($scope, $http) {
  $scope.bowlOfFruit = [
    {name: 'Apple'},
    {name: 'Pear'},
    {name: 'Orange'}
  ];
});

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi rigoberto contreras,

I would highly recommend you have a read over the official AngularJS docs for the ngRepeat directive as you seem confused by how loops work in Angular, in any case you only need one LI element and instead of name been the variable I recommend you choose something meaningful such as fruit since we're listing out items within bowlOfFruit.

<ul>
  <li ng-repeat="fruit in bowlOfFruit">
    {{fruit.name}}
  </li>
</ul>

Happy coding!