1. For this example I am using php server side code to gather the data from the data base and return it as a Json format. For this we can use the buid in code for php i.e.
json_encode($data);
for eg: (using Codeigniter model)
$check_sql = "Select * from user where about_status = 1"; //status is flag for the active user
$check = $ci->db->query($check_sql);
$row = $check->result();
echo json_encode($row);
which gives output as:
{
"records": [
{
"Name" : "Yubraj Pokharel",
"City" : "Kathmandu",
"Country" : "NP"
},
{
"Name" : "Chitra Shrestha",
"City" : "Pokhara",
"Country" : "NP"
},
{
"Name" : "Prayag Upd",
"City" : "California",
"Country" : "US"
},
{
"Name" : "Sudhan Pokharel",
"City" : "Nepalgunj",
"Country" : "NP"
},
{
"Name" : "Mr Tom Cruise",
"City" : "California",
"Country" : "US"
}
]
}
2. calling it from the angular page:
<html>
<head>
<title>Json Data</title>
call angular js here
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-12" ng-app="myApp" ng-controller="customersCtrl">
<table class="table">
<tr>
<th>Name</th>
<th>country</th>
</tr>
<tr ng-repeat="x in names">
<td>{{ x.Name }} </td>
<td>{{ x.Country }}</td>
</tr>
</table>
</div>
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("http://localhost/angular/news.php")
.success(function(response) {$scope.names = response.records;});
});
</script>
</body>
</html>
3. Here it is done enjoy happy coding :)
json_encode($data);
for eg: (using Codeigniter model)
$check_sql = "Select * from user where about_status = 1"; //status is flag for the active user
$check = $ci->db->query($check_sql);
$row = $check->result();
echo json_encode($row);
which gives output as:
{
"records": [
{
"Name" : "Yubraj Pokharel",
"City" : "Kathmandu",
"Country" : "NP"
},
{
"Name" : "Chitra Shrestha",
"City" : "Pokhara",
"Country" : "NP"
},
{
"Name" : "Prayag Upd",
"City" : "California",
"Country" : "US"
},
{
"Name" : "Sudhan Pokharel",
"City" : "Nepalgunj",
"Country" : "NP"
},
{
"Name" : "Mr Tom Cruise",
"City" : "California",
"Country" : "US"
}
]
}
2. calling it from the angular page:
<html>
<head>
<title>Json Data</title>
call angular js here
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-12" ng-app="myApp" ng-controller="customersCtrl">
<table class="table">
<tr>
<th>Name</th>
<th>country</th>
</tr>
<tr ng-repeat="x in names">
<td>{{ x.Name }} </td>
<td>{{ x.Country }}</td>
</tr>
</table>
</div>
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("http://localhost/angular/news.php")
.success(function(response) {$scope.names = response.records;});
});
</script>
</body>
</html>
3. Here it is done enjoy happy coding :)
Pleasant Post. It is truly intriguing to peruse from the earliest starting point and I might want to share your site to my circles, continue sharing more like this.
ReplyDeleteAngularjs courses in Chennai | Angularjs Training in Chennai
This technical post helps me to improve my skills set, thanks for this wonder article I expect your upcoming blog, so keep sharing...
ReplyDeletePHP Training Institute in Chennai|Best PHP training in chennai
Excellent post! Thank you for Sharing. We are the best erp software providers in chennai. For more details call +91 9677025199 or email us on info@bravetechnologies.in
ReplyDeleteerp in chennai
Excellent post! I heve read your blog it's very interesting and informative. Keep sharing.
ReplyDeleteerp providers in chennai | erp software chennai
Your post is useful for me. Thanks for sharing this technical information with us. Great effort.
ReplyDeletePHP training classes | PHP training institute in chennai
Thanks for sharing such informative article. Know about Know about English to Tamil from techfizy.
ReplyDeleteWonderful post!!Thank you for sharing this info with us.
ReplyDeleteKeep updating I would like to know more updates on this topic
Very useful content, I would like to suggest this blog to my friends.
PHP Course Chennai
PHP Training Chennai
Nice Post I learned a lot From the Post Thanks for sharing, learn the most ON-DEMAND software Training in Best Training Institutions
ReplyDeleteInstructor-LED Salesforce Online Training
Professional Salesforce CRM Training
Salesforce Training online in India
wow great Article, the details you have provided are much clear, easy to understand, if you post some more Article, it will be very much useful for me.
ReplyDeletePHP Training in Chennai
The blog you presented was very nice and interesting which helped me to get update on the recent technologies.
ReplyDeleteangularjs training in chennai
devops training in chennai
Thanks for sharing the valuable post. Kanhasoft is the well known Custom PHP Web Developer in India. We providing outsourcing services to USA, UK, Europe, Canada, Germany, UAE, Dubai, Australia, France, Brazil, Turkey, Singapore, Japan, Saudi Arabia, Ukraine, Spain, Belgium, Netherlands, Luxembourg, New Zealand, Argentina, South Africa, Greece, Denmark, Poland, Switzerland and more. Visit our site to know more.
ReplyDelete
ReplyDeleteWell done! superb post, this content is very useful for me. I eagerly waiting for your next posts.
Power BI Training in Chennai
Power BI Training Fees in Chennai
Embedded System Course Chennai
Linux Training in Chennai
Tableau Training in Chennai
Spark Training in Chennai
Unix Training in Chennai
Oracle Training in Chennai
Oracle DBA Training in Chennai
This comment has been removed by the author.
ReplyDeleteMy developer is trying to convince me to move to .net from PHP. I have always disliked the idea because of the expenses. But he’s trying none the less. I’ve been using Movable-type on several websites for about a year and am anxious about switching to another platform. I have heard great things about blogengine.net. Is there a way I can transfer all my Word Press posts into it? Any help would be appreciated. DevOps Training in Bangalore good work
ReplyDeleteAi & Artificial Intelligence Course in Chennai
PHP Training in Chennai
Ethical Hacking Course in Chennai Blue Prism Training in Chennai
UiPath Training in Chennai
With the evolvement of Salesforce it has become the need of the hour for individuals to keep themselves updated with the latest developments. Salesforce training in Chennai
ReplyDeleteThanks for sharing your knowledge with us. I got more good ideas from your blog.
ReplyDeletecrm strategy example
Benefits of Artificial Intelligence
python is used for
why cloud computing is needed
oracle pl sql interview questions
data scientist interview questions and answers
Mua vé tại Aivivu, tham khảo
ReplyDeletekinh nghiệm mua vé máy bay đi Mỹ giá rẻ
vé máy bay từ mỹ đi việt nam
giá vé máy bay từ Vancouver về việt nam
bay nhật bản việt nam
vé máy bay hàn quốc hà nội
Vé máy bay từ Đài Loan về Việt Nam
giá khách sạn cách ly ở việt nam