Apologies for the poorly worded question, I am struggling with the logic of this one.
I have the following JSON array:
{
"status": {
"available": [
{
"title": "Currently available for contracts" ,
"dateAvailable": null,
"company": null
}
],
"on-assignment": [
{
"title": "Currently Unavailable" ,
"dateAvailable": "2015-03-25",
"company": "BBQ Digital"
}
],
"on-holiday": [
{
"title": "Currently on holiday" ,
"dateAvailable": null,
"company": null
}
]
}
}
Coupled with the following controller:
.controller('statusCtrl', function($scope, $http) {
$scope.astatus = [];
$http.get('app/model/status.json')
.success( function(response) {
$scope.astatus = response;
})
.error( function(err) {
alert(err);
});
})
Using AngularJS (v1.3.14) I want to check a variable to see if I am 'available', 'on-assignment' or 'on-holiday' and to display the 'title', 'dateAvailable' and 'company' attributes of the correct status section. In a manner similar to this (excuse the pseudocode):
<div class="cta">
// display the correct title
{{ status.[next level].title }}
if (on-assignment) {
<span>Currently working for:</span>
{{ status.[next level].company}}
<span>I will be available on:</span>
{{ status.[next level].dateAvailable}}
}
<a href="#contact" class="button">Get in touch</a>
</div>
I've included the pseudocode on the template to make what I"m after clear, however if possible, I'd prefer this logic to be in the controller.
I am a good JavaScript/jQuery developer, however my experience with JSON is limited to much simpler stuff and I'm a complete beginner at AngularJS so please bear that in mind in your answers.
Note: As I'm trying to learn, explaining your answers would be hugely helpful.