In Angular JS ng-repeat directives use for collection show in table. $http service use for to call API.
Ex.
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis. com/ajax/libs/angularjs/1.4.8/ angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="customersCtrl">
<p><input type="text" ng-model="test"></p>
<table>
<tr><th ng-click="orderByMe('name')"> Company Name</th><th ng-click="orderByMe('country') ">Price</th><th>Price Difference</th><th>Date</th></ tr>
<tr ng-repeat="x in MyData | filter : test">
<td>{{ x.co_name }}</td>
<td>{{ x.price }}</td>
<td>{{ x.price_diff }}</td>
<td>{{ x.tr_date }}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl' , function($scope, $http) {
$http.get("http://cmapis. cmots.com/ashlar/Equity/ Market.svc/Ticker/bse? responsetype=json&limit=5"). then(function (response) {
//alert(JSON.stringify(response. data.response.data));
$scope.MyData = response.data.response.data. companylist.company;});
});
</script>
</body>
</html>
No comments:
Post a Comment