0

I am not able to access array values one by one here is plunker

https://plnkr.co/edit/58HdYqZUi30kRaNgT3V3?p=preview

I am just accessing this, but it is not printing anything.

     <div ng-repeat=" day in excDays">
     <p>{{day}}</p>
      </div>
2
  • i have corrected it based on below comments now it works fine Commented Jul 22, 2016 at 9:30
  • Mark as answered then. Commented Jul 22, 2016 at 9:40

5 Answers 5

2

You are closing the <div> without printing anything in it:

<div ng-repeat="day in excDays">
    <span ng-bind="day"></span>
</div>

The values from the ng-repeat are only available inside the element.

Sign up to request clarification or add additional context in comments.

Comments

1

Try like this , You have to put {{day}} inside ng-repeat div

   <body ng-app="plunker" ng-controller="MainCtrl">
        <div ng-repeat="day in excDays">
        <p>{{day.dayName}}</p>
        </div>
  </body>

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
     $scope.excDays = [
			    {
					dayNum: 1,
					dayName: 'Monday'
				}, {
					dayNum: 2,
					dayName: 'Tuesday'
				}, {
					dayNum: 3,
					dayName: 'Wednesday'
				}, {
					dayNum: 4,
					dayName: 'Thursday'
				}, {
					dayNum: 5,
					dayName: 'Friday'
				}, {
					dayNum: 6,
					dayName: 'Saturday'
				},{
					dayNum: 0,
					dayName: 'Sunday'
			   }];
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
  <body ng-app="plunker" ng-controller="MainCtrl">
    <div ng-repeat="day in excDays">
    <p>{{day.dayName}}</p>
    </div>
    </body>

Comments

1

You need to put the p inside the div with the ng-repeat

<div ng-repeat="day in excDays">
  <p>{{day}}</p>
</div>

Updated plnkr https://plnkr.co/edit/1JKLBRe4wfS6SPXNKz7t?p=preview

Comments

0

The problem is that your day is only usable inside the div, and you are closing it and then you call day outside of that div.

Comments

0

Yo should place <p> inside <div> tag. {{day}} is out of scope.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.