I am creating a "word of the day" functionality in a web app and I have a JSON file with the following data structure. I couldn't get myself to dump 730+ entries into the HTML under ng-init to filter by day.
{"words":[
{
"day":"0",
"aramaic":"mi<u>t</u>ra",
"english":"rain"
},
{
"day":"1",
"aramaic":"libba",
"english":"heart"
}]
}
I have the JSON file being called in the controller and trying to bring it in via scope.
$http.get('content/words.json').success(function(data) {
var pairNum, prevPage, nextPage;
pairNum = 1;
$scope.word = {
all:data,
day:parseInt(data.words[pairNum]["day"]),
eng:data.words[pairNum]["english"],
cha:data.words[pairNum]["aramaic"],
limit:data.words.length
}
});
To my demise, I am unable to bring the JSON data to the HTML via $scope.word.all to filter. I would greatly appreciate help here, or a different way to architect this solution if I am approaching it wrong.
Here is how the HTML looks
<div class="row" ng-init="words = word.all">
<h2>CHALDEAN WORD OF THE DAY</h2>
<div class="small-2 columns"><a ng-click="word.day = word.day - 1"><span ng-show="word.day > 1" class="foundicon-left-arrow"> <span></a></div>
<div class="small-8 columns" ng-repeat="word in words | filter:word.day"><h4 class="wotd">{{word.english}} :: {{word.chaldean}} :: {{word.day}}<h4></div>
<div class="small-2 columns"><a ng-click="word.day = word.day + 1"><span ng-show="word.day < word.limit" class="foundicon-right-arrow"> <span></a></div></div><!-- .row -->
Thank you in advance to all that will attempt.
Ps. I already have a feeling I will be screwed with the <u> in the JSON.