我遇到了我的角度应用程序的问题,我试图ng-repeat
在视图上的数组将登录到控制台但不会显示在页面上。
这是我在我的控制器中的功能
var calCells = document.getElementsByClassName('calendar-cell');
for(i = 0; i < calCells.length; i++){
calCells[i].addEventListener('click', updateDay, false);
}
var todayCell = document.getElementsByClassName('today');
todayCell[0].addEventListener('click',updateDay,false);
} // renderCalender function ends
function displayDayPosts(selectedDay) {
$scope.displayDay = happyService.setDisplayPosts(selectedDay);
console.log($scope.displayDay);
}
var updateDay = function(){
var thisCellTime = this.querySelector('time');
var selectedDate = thisCellTime.getAttribute('datetime');
//onclick text//
displayDayPosts(selectedDate);
console.log(selectedDate)
}
这是我在工厂中获取对象的地方
function setDisplayPosts(selectedDay) {
var days = getDays();
var day = {posts: []};
for(i=0; i < days.length; i++){
if(selectedDay.substring(0,10) === days[i].date.substring(0,10)){
day.newAvg = days[i].average;
days[i].forEach(function(post){
var postObj = {};
postObj.mood = post.mood;
postObj.comment = post.comment;
postObj.rating = post.rating;
postObj.date = post.date;
day.posts.push(postObj);
});
}
}
return day;
}
以下是我在页面上显示它的方式
<div ng-repeat="entry in displayDay.posts track by $index" class="entry">
<h4 class="entry-title">{{entry.date | date }}</h4>
<p class="rating-display"><strong>Rating:</strong> {{entry.rating}}</p>
<p class="comment-display"><strong>Comment:</strong> {{entry.comment}}</p>
<p class="moods-display"><strong>Moods:</strong> {{entry.mood}}</p>
</div>
对象displayDay正如我在控制台中所期望的那样进行记录。
任何帮助将不胜感激。谢谢!