Please help me figure it out. I want to access the array value by key (in blockquote block), but nothing works and there are no errors in the console, the code is:
<div class="container"> <div class="row row-content" ng-controller = "dishDetailController as dishCtrl"> <div class="col-xs-12"> <div class="media-list media-list tab-pane fade in active"> <div class="media" ng-repeat="dish in dishCtrl.dish"> <div class="media-left media-middle"> <a href="#"> <img class="media-object img-thumbnail" ng-src={{dish.image}} alt="Uthappizza"> </a> </div> <div class="media-body"> <h2 class="media-heading">{{dish.name}} <span class="label label-danger">{{dish.label}}</span> <span class="badge">{{dish.price | currency}}</span> </h2> <p>{{dish.description}}</p> </div> </div> </div> </div> <div class="col-xs-9 col-xs-offset-1"> <p><h4>Customer Comments</h4>Sort by:<input type="text" id="comm"> <blockquote ng-repeat="comment in dishCtrl.dish.comments"> <p>{{comment.rating}} Stars</p> <p>{{comment.comment}}</p> <footer>John Lemon</footer> </blockquote> </div> Script:
var app = angular.module('confusionApp',[]); app.controller('dishDetailController', function() { var dish=[{ name:'Uthapizza', image: 'images/uthapizza.png', category: 'mains', label:'Hot', price:'4.99', description:'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.', comments: [ { rating:5, comment:"Imagine all the eatables, living in conFusion!", author:"John Lemon", date:"2012-10-16T17:57:28.556094Z" }, { rating:4, comment:"Sends anyone to heaven, I wish I could get my mother-in-law to eat it!", author:"Paul McVites", date:"2014-09-05T17:57:28.556094Z" }, { rating:3, comment:"Eat it, just eat it!", author:"Michael Jaikishan", date:"2015-02-13T17:57:28.556094Z" }, { rating:4, comment:"Ultimate, Reaching for the stars!", author:"Ringo Starry", date:"2013-12-02T17:57:28.556094Z" }, { rating:2, comment:"It's your birthday, we're gonna party!", author:"25 Cent", date:"2011-12-02T17:57:28.556094Z" } ] } ]; this.dish = dish; }); </script>
dishCtrl.dish.commentsdoes not exist, thecommentsattribute is defined on the listdishCtrl.dish- nörbörnën<blockquote ng-repeat="comments in dishDetailController.dish"> <p>{{comments.rating}} Stars</p> <p>{{comments.comment}}</p> <footer>John Lemon</footer> </blockquote>It doesn't work either ( - I.Swenblockquote ng-repeat="comment in dishCtrl.dish.comments">elementblockquote ng-repeat="comment in dishCtrl.dish.comments">is outside thedishDetailControllercontroller. - Stepan Kasyanenko