i have large json file structured following i'm trying loop on in angular:
{ "subject1":[ { "title":"titlehere", "info":"infohere." }], "subject2":[ { "title":"titlehere", "info":"infohere." }], "subject3":[ { "title":"titlehere", "info":"infohere." }] } i want page grab key each 'category' , display title underneath it. i'm able key display can't seem figure out how grab string each title. have in html:
<div ng-repeat="(key, value) in faqs"> <h3>{{ key }}</h3> <ul> <li><a href="#" ng-click="showhide(pageinfo)">{{ value }}</a></li> </ul> </div> i'm not sure should using instead of {{ value }} grabs nothing entire json file string. tried {{ value.title }} , still had no luck.
any suggestions?
use {{ value[0].title }}
your code be
<div ng-repeat="(key, value) in faqs"> <h3>{{ key }}</h3> <ul> <li ng-repeat="val in value"><a href="#" ng-click="showhide(pageinfo)">{{ val.title }}</a></li> </ul> </div>
Comments
Post a Comment