Sometimes, we need to display information on the web page dynamically. There may be the cases when data is being collected on regular or irregular intervals. In those situations, data is fetched from third party locations in form of interoperable notations using exposed services.
Now the question is “Does AngularJS support this feature and can it help us to give solution in this case?”
The answer is YES!
Data source is situated at remote location to our AngularJS application. So we need a language or special notion which can be transmited and understood by AngularJS.
That special light weighted notation is JAVA SCRIPT OBJECT NOTATION (JSON). Remote web service returns data in JSON formation, which is consumed and post compilation it is used by AngularJS application.
Hence AngularJS is perfect to display data from database provided data should be in JSON format. As AngularJS is JavaScript based framework, it works for PHP, ASP.Net and many more…
In this article, we are considering ASP.NET for demonstration.
Assume it that we have a table in SQL Server with data which is represented below:
Data Source
Location | Country |
Delhi | India |
New York | USA |
We need a web service which provides above data in JSON format. Let’s say:
Web Service
http://hostname/locations.aspx
It returns data in JSON format as below:
{“records”:[ { “Location” : “Delhi”, “Country” : “India” }, { “Location” : “New York”, “Country” : “USA” } ]}
Above mentioned URL can be used in AngularJS application using AngularJS service $http.
AngularJS Application
Output
Delhi | India |
New York | USA |
Let’s see, how is the code of locations.aspx written?
Be Connected…
Satyendra Mishra
THREE QUERIES offers easy access to information about SharePoint and associated technologies, project management, agile and scrum methodologies that helps developers, administrators, architects, technical managers, business analysts and end users. It has grown from there. We provide an important knowledge base for those involved in managing, architecture and developing software projects of all kinds. With weekly/daily exclusive updates, we keep you in touch with the latest business, management, technology thinking.
WE ARE CONNECTED ~ Follow us on social media to get regular updates and opinion on what's happening in the world of SharePoint, front-end, back end web technologies and project management. If you like this article, please share it and follow us at Facebook, Twitter, Instagram, Pinterest and LinkedIn