I'm currently working with Foundation for Apps, a framework that incorporates elements of AngularJS. My goal is to display the content from a local JSON file by accessing it through a controller and rendering the results as 'cards'. Additionally, I would like the data set to be searchable.
Currently, I have set up a page with the following code snippet:
<div class="grid-container">
<div class="grid-block">
<div ng-model="providers" class="grid-content">
{{providers}}
</div>
</div>
</div>
In my controllers.js file, I added the following code:
var myApp = angular.module('application',[]);
App.controller('ProvidersCtrl', function($scope, $http) {
$http.get('providers.json')
.then(function(res){
$scope.providers = res.data;
});
});
The head section of my index.html file includes:
<!doctype html>
<html lang="en" ng-app="application">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Provider Directory</title>
<link href="/assets/css/app.css" rel="stylesheet" type="text/css">
<script src="/assets/js/foundation.js"></script>
<script src="/assets/js/templates.js"></script>
<script src="/assets/js/routes.js"></script>
<script src="/assets/js/controllers.js"></script>
<script src="/assets/js/app.js"></script>
</head>
Despite following these steps, I am encountering issues with displaying the data on the screen. I suspect that it may be due to a misunderstanding of AngularJS and how the data should be handled.
Attached below is a sample JSON data structure:
[
{
"specialty": "Cardiovascular Disease",
"registered": "Sunday, January 25, 2015 5:37 AM",
... (additional information)
},
{
"specialty": "Urology",
"registered": "Friday, November 21, 2014 8:24 AM",
... (additional information)
}
]
Edit: Despite my efforts, I'm still experiencing difficulties in deploying the data to the user interface.
Edit 2: Updated the JSON format to remove an unnecessary providers = '
at the beginning.
Unfortunately, the content is not being displayed as intended. Any guidance or assistance would be greatly appreciated.