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

Micah Dunson
Micah Dunson
34,368 Points

Not sure how to iterate over arrays

I'm not sure what I'm missing on this challenge. It would seem everything is ok but I keep getting the error about my text not being correct. Not sure what that means and what I;m doing wrong.

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 id="bowlOfFruit">
    <li ng-repeat="name in bowlOfFruit">
      <span class="name">
        {{bowlOfFruit.name}}
      </span>
    </li>
  </ul>
</body>
</html>
app.js
angular.module('myApp', [])
.controller('myController', function ($scope, $http) {
  $scope.bowlOfFruit = [
    {name: 'Apple'},
    {name: 'Pear'},
    {name: 'Orange'}
  ];
});

1 Answer

Michael Hess
Michael Hess
24,512 Points

Hi Micah,

Try this:

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

Hope this helps!

Micah Dunson
Micah Dunson
34,368 Points

I'm a little confused as too why and how that works when "fruit" isn't referenced anywhere unlike "name".