I am new to Angular js and i wanted to pass one static json file through ajax and i am giving the codes below.How to Display the data of json file into the index file that i dont know. As i am new to angularjs please help me with these
Index.php
<body ng-app="Mymodule">
<div ng-controller="recordscontroller">
<table style="width:500px; border:solid 2px #CCC;">
<thead>
<tr style="text-align:left;">
<th>First Name</th>
<th>Last Name</th>
<th>Gender</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="emp in employee | orderBy : '-salary'">
<td>{{ emp.firstname }}</td>
<td>{{ emp.lastname }}</td>
<td>{{ emp.gender }}</td>
<td>{{ emp.salary | currency: 'Rs' }}</td>
</tr>
</tbody>
</table>
</div> <br>
</body>
Script.js
var app = angular.module("Mymodule",[]);
app.controller("recordscontroller", function($scope, $http){
var url = "data/records.json";
$http.get(url).success(function (response){
$scope.employee = response;
});
});
records.json
[
{
"firstname":"Kishan",
"lastname":"Dalsania",
"gender":"Male",
"salary":15000
},
{
"firstname":"Dipesh",
"lastname":"Mungara",
"gender":"Male",
"salary":20000
},
{
"firstname":"Roshan",
"lastname":"Trivedi",
"gender":"Male",
"salary":25000
},
{
"firstname":"Jay",
"lastname":"Dalsania",
"gender":"Male",
"salary":30000
},
]
},
->}