I'm new to AngularJS and JS based web development, and I'm trying to make my portfolio site as a single page AngularJS application. I want to put all of my previous project data in a JSON file and use JS to grab the data and display it dynamically in an HTML list or table. I've tried doing a lot of research on this, but it's not working. My code is posted below.
myApp.controller('portController', function($scope, $http){
$scope.test = "TEST PHRASE";
$http.get('../projects.json').success(function(data) {
$scope.projects = data;
});
});
<div class="jumbotron text-center">
<h1>Portfolio Home</h1>
<p>{{ test }}</p>
<table>
<tr ng-repeat="project in projects">
<td>{{project.title}}</td>
<td>{{project.date}}</td>
</tr>
</table>
</div>
[
{
"title" : "Sample Title",
"date" : "01/01/2001"
},
{
"title" : "Sample Title 2",
"date" : "02/02/2002"
}
]
NOTE: I have a JS file that controls what is displayed on the page based on the URL (it handles all routing), and I am using ng-view and changing the controller to use the html above when on a certain page. The {{test}} bit worked fine until I added in the http request.