I'm looking to see why a very simple Angular filter isn't working for me in example. Everything I've found online points to this format but it doesnt seem to work. Basically, I just want the information for the array that contains the value "completed" as the status. Here's my code:
<div class="span12" id="trainingWidget" ng-controller = "trainingInfo">
<div class="span3 pull-right">
<h4 class="theme-color">Available Courses</h4>
<table id="courseList">
<thead>
<tr>
<th>Location</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in training | limitTo : 6">
<td>{{item.location}}</td>
<td>{{item.date}}</td>
</tr>
</tbody>
</table>
</div>
<div class="span3 pull-right">
<h4 class="theme-color">Your Last Course</h4>
<div id="courseStatus">
<p ng-repeat="item in training | limitTo: 1 | filter: {status: completed}">Was completed on <span id="recentTrainingDate">{{item.completionDate}}</span><br />
<span id="recentTrainingTitle">{{item.name}}</span></p>
<p class="theme-color">STATUS</p>
<p><i class="icon icon-ok"></i> Up To Date</p>
</div>
</div>
</div>
And here is the JSON:
[
{
"location": "Cincinnati, OH",
"date": "Feb 18, 2016",
"name": "ABC Certification",
"status": "future",
"completionDate": ""
},
{
"location": "Houston, TX",
"date": "Mar 1-3, 2016",
"name": "123 Certification",
"status": "future",
"completionDate": ""
},
{
"location": "Cincinnati, OH",
"date": "Apr 26-28, 2016",
"name": "Master Trainer Certification",
"status": "future",
"completionDate": ""
},
{
"location": "Houston, TX",
"date": "May 15-17, 2016",
"name": "ABC Certification",
"status": "future",
"completionDate": ""
},
{
"location": "Cincinnati, OH",
"date": "July 12-14, 2016",
"name": "123 Certification",
"status": "future",
"completionDate": ""
},
{
"location": "Houston, TX",
"date": "Sept 28-29, 2016",
"name": "Birkman Method® Certification Training",
"status": "future",
"completionDate": ""
},
{
"location": "Houston, TX",
"date": "Nov 9-11, 2015",
"name": "Birkman Method® Certification Training",
"status": "completed",
"completionDate": "July 15, 2015"
}
]
I dont think its nessessary but here is the controller snippet:
myBirkman.controller('trainingInfo', ['$scope', '$http', '$filter', function($scope, $http, $filter) {
$http.get('assets/js/lib/angular/trainingData.json').success(function(data) {
$scope.training = data;
});
}]);
The first ng-repeat works perfectly, but on the second repeat, I just want to show the first array that contains "completed" as the value of "status". Thanks in advanced for your help.