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 trialMicah Dunson
34,368 PointsNot 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.
<!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>
angular.module('myApp', [])
.controller('myController', function ($scope, $http) {
$scope.bowlOfFruit = [
{name: 'Apple'},
{name: 'Pear'},
{name: 'Orange'}
];
});
1 Answer
Michael Hess
24,512 PointsHi Micah,
Try this:
<ul>
<li ng-repeat="fruit in bowlOfFruit">
{{fruit.name}}
</li>
</ul>
Hope this helps!
Micah Dunson
34,368 PointsMicah Dunson
34,368 PointsI'm a little confused as too why and how that works when "fruit" isn't referenced anywhere unlike "name".