Hi All.
So let's start with the requirements.
Requirement: Get all the list items and display them in a specific format. (Actually here we have multiple options to satisfy this requirement including a List Viewer web part or writing a simple script in JavaScript and showing the result in either a Content Editor web part or a Script Viewer web part. Since we need to explore AngularJS and MVC patterns using it we will go with the AngularJS option.)
We can use any type list, here I am using an OOB link list as in the following:
Figure 1: OOB Link List
Since this is my first article, I'll use only one JavaScript file for now and show the results in a Content Editor web part. In the next article I'll divide code into multiple files as in the MVC architecture.
For using AngularJS we need to include a reference to the AngularJS. Either we can use it directly from CDN or download and copy it into the _layouts folder or upload into the master pages gallery like display templates. For now, I have downloaded it and copied to the _layouts/15/AngularJSDemo folder.
The following is the snippet for displaying the data (in other words, View):
- <div ng-app="list-module">
- <div ng-controller="list-controller">
- <ul style="list-style-type:none;">
- <li ng-repeat="item in listitems" style="align:left;>
- {{item.URL.Description}}{{item.URL.Url}}
- </li>
- </ul>
- </div>
- </div>
The key point here is we are getting the list items in listitems and we are looping using ng-repeat and displaying those. Since we are using a link list, we are displaying the link URL and link description.
The next is a script for getting the list items using Rest APIs.
- <script src="_layouts/15/AngularJSDemo/angular.min.js"></script> //AngularJS reference
- <script type="text/javascript">
- var spApp= angular.module('list-module', []);
- spApp.controller('list-controller', function($scope, $http){
- $http({
- url: _spPageContextInfo.webAbsoluteUrl + "/_api/lists/getbytitle('Linkit')/items", //assuming web part is added on same site :)
- method: "GET",
- headers: { "Accept": "application/json;odata=verbose" }
- }).success(function (data) //got the result successfully
- {
- var dataResults = data.d.results; // List Items
- $scope.listitems = dataResults;
- })
- .error(function (data, status, headers, config) // got the error
- {
- alert("error"); //ToDo:Display proper error message/Stack Trace/ Status Code
- });
- });

Figure 2: Link our JavaScript file in CEWP
References:
AngularJS: https://angularjs.org/
https://docs.angularjs.org/misc/downloading
http://www.w3schools.com/angular/angular_directives.asp
$scope: https://docs.angularjs.org/guide/scope
REST APIs:
https://msdn.microsoft.com/en-us/library/office/jj860569.aspx
https://msdn.microsoft.com/en-us/library/office/fp142380.aspx
https://msdn.microsoft.com/en-us/magazine/dn198245.aspx
https://msdn.microsoft.com/en-us/library/office/jj164022.aspx
I'll write part 2 soon explaining the MVC pattern with AngularJS. Thanks! Your feedback, suggestions, comments and/or queries are always welcome.

Sr KarthigaPosted Apr 3, 2016, 12:02 AM
good one
Sr KarthigaPosted Apr 3, 2016, 12:02 AM
nice explanation
Prasham SabadraPosted Jul 23, 2015, 12:46 AM
Hi Maninder, I'll check once may be on weekend. I'll update. But glad to hear this article helps you. Also thanks a lot for your very important comments.
Maninder SinghPosted Jul 21, 2015, 12:11 PM
Thanks for sharing this value able information . it was my first try on angular and rest and it proved to be bit easy with the help of your blog. But i faced a issue while using it . there was problem with angular expression as per your code it is "{{item.URL.Description}}{{item.URL.Url}} " and i modified it to "{{item.Description}}{{item.Url}}" and it started working. I am totaly new to this stuff so cant even say that its a bug please check and correct it if it is an issue so that someone else can also use it without facing any problem ... thanks a lot again for this stuff :)
Prasham SabadraPosted Jul 6, 2015, 6:35 AM
Thanks Sriram :)
SriramPosted Jul 6, 2015, 3:01 AM
Good.............
Prasham SabadraPosted Jun 24, 2015, 6:07 AM
Thanks a lot Shriram!
Shriram PophaliPosted Jun 24, 2015, 6:05 AM
Nice Article Prasham! Just observed couple of typos in code snippet. In first code snippet, ending double quote is missing in attribute style="align:left;> and in second end tag </script> is missing for <script> tag. Thanks!
Prasad PathakPosted May 22, 2015, 10:38 PM
Nice and informative article Prasham
Manas MoharanaPosted Apr 14, 2015, 12:14 AM
Good Article on both Rest Api and Angular JS
Karthik Muthu KaruppanPosted Apr 13, 2015, 1:34 PM
Nice
Sibeesh VenuPosted Apr 13, 2015, 1:57 AM
Good one :)
Santhakumar MunuswamyPosted Apr 12, 2015, 11:07 PM
good