Hope you have had a chance to look into my last tutorial which talks about the technology stack and creating the UI html page with module and controller, Event Binding with UI elements, and Routing in Angular JS with partial templates. Kindly find the links here:
- AngularJS And ASP.NET MVC Movie Library Application - Part One
- AngularJS And ASP.NET MVC Movie Library Application - Part Two
- AngularJS And ASP.NET MVC Movie Library Application- EventBinding with UI Elements - Part Three
- AngularJS And ASP.NET MVC Movie Library Application - AngularJS Routing with partial templates - Part Four
Moving ahead, in this article, we’ll focus on the integration of live movie API within an existing application.
Kindly open the given URL and register yourself. After registering, you will get a token which we’ll be using in this article to retrieve the information/data from API.
http://api.myapifilms.com/imdb
Once you register yourself, you should receive an email like the given image, with some token value.

Open the website with the link, shared above, and fill in the details, as shown below in the following images.


As soon as you click on the submit button, you should receive a response in JSON format, as given below:

You may also get XML response for just making amendments either in request or in format dropdown, as shown below:

So far so good. We are now able to use this API URL within our application.
Open you solution and find routing.js file to add a new Controller into this, as give below:

- routingApp.controller("ApiMovieController", ['$scope', '$http', '$timeout', function ($scope, $http, $timeout) {
- $scope.SearchMovieByTitle = function () {
- var title = $scope.searchByTitle;
- alert(title);
- $http.jsonp("http://api.myapifilms.com/imdb/idIMDB?title=" + title + "&token=5bf98789787hghjg4&format=json&language=en-us&aka=0&business=0&seasons=0&seasonYear=0&technical=0&filter=2&exactFilter=0&limit=5&forceYear=0&trailers=0&movieTrivia=0&awards=0&moviePhotos=0&movieVideos=0&actors=0&biography=0&uniqueName=0&filmography=0&bornAndDead=0&starSign=0&actorActress=0&actorTrivia=0&similarMovies=0&adultSearch=0&goofs=0"es=0&fullSize=0&companyCredits=0&callback=JSON_CALLBACK").success(function (response) {
- console.log(response);
- $scope.movies = response.data.movies;
- })
- }]);
Note: If you have noticed, in the above code segment, you have injected a dependency $http and $timeout. For now, only concentrate on the $http and forget about $timeout.

Complete code for routing.js main JavaScript file is shown below:
Code Routing.js file
- /// <reference path="../Scripts/angular.js" />
- /// <reference path="../Scripts/fusioncharts.js" />
- /// <reference path="../Scripts/fusioncharts.charts.js" />
- /// <reference path="DataService.js" />
- /// <reference path="../Scripts/angular-route.js" />
- var routingApp = angular.module('routingApp', ['ngRoute']);
- routingApp.directive("login", function () {
- var directive = {};
- //restrict = E, signifies that directive is Element directive
- directive.restrict = 'E';
- //template replaces the complete element with its text.
- directive.templateUrl = "/Application/Login.html";//"My first directive";
- return directive;
- });
- routingApp.config(['$routeProvider', function ($routeProvider) {
- //alert("Route Initiated");
- $routeProvider.
- // when('/Home', { templateUrl: '/Application/login.html', controller: 'DotnetPiperController' }).
- when('/Movie', { templateUrl: '/Application/Movie.html', controller: 'MovieController' }).
- when('/SearchMovie', { templateUrl: '/Application/SearchMovie.html', controller: 'ApiMovieController' }).
- when('/Tolly', { templateUrl: '/Application/Tollywood.html', controller: 'tollyController' }).
- otherwise({ redirectTo: '' });
- }]);
- routingApp.controller("tollyController", function ($scope) {
- $scope.tollyMessage = "Welcome to TollyWood to watch Action,Thriller and Suspence movies";
- });
- routingApp.controller("MovieController", ['$scope', function ($scope) {
- $scope.edit = false;
- $scope.message = "Welcome to DotnetPiper.com to learn Angular";
- $scope.error = false;
- $scope.clear = false;
- $scope.success = false;
- // alert("Servcie Called");
- var movies = [
- { title: "Revenent", year: "2015", rating: "5Star", plot: " A revenger Journey" },
- { title: "Counjouring2", year: "2016", rating: "4Star", plot: " A Complete Hourror" },
- { title: "DDLJ", year: "1995", rating: "SuperStar", plot: "Romantic love story" },
- { title: "Sultan", year: "2016", rating: "5Star", plot: "A Warrior" },
- { title: "BajiRao Mastani", year: "2015", rating: "4.5 Star", plot: "Film of the Year" }
- ];
- $scope.movies = movies;
- $scope.AddMovie = function (movie) {
- if ($scope.edit == true) {
- var index = $scope.movies.indexOf(movie);
- // alert("edit Called");
- $scope.movies[index] = movie;
- //alert(movie.rating);
- $scope.updatedMovie = movie;
- $scope.success = true;
- $scope.movie = {};
- }
- else {
- var newMovie = {
- title: $scope.movie.title,
- year: $scope.movie.year,
- rating: $scope.movie.rating,
- plot: $scope.movie.plot
- };
- movies.push(newMovie);
- // alert("Add Called");
- }
- }
- $scope.DeleteMovie = function (movie, index) {
- movies.splice(index, 1);
- // $scope.movie = movie;
- $scope.updatedMovie = movie;
- $scope.success = false;
- $scope.clear = true;
- $scope.movie = {};
- console.log(index);
- }
- $scope.EditMovie = function (movie, index) {
- $scope.selectedRow = null; // initialize our variable to null
- $scope.selectedRow = index;
- $scope.movie = movie;
- $scope.edit = true;
- }
- }]);
- routingApp.controller("ApiMovieController", ['$scope', '$http', '$timeout', function ($scope, $http, $timeout) {
- $scope.SearchMovieByTitle = function () {
- var title = $scope.searchByTitle;
- alert(title);
- $http.jsonp("http://api.myapifilms.com/imdb/idIMDB?title=" + title + "&token=5bf5tr54-793f-4a6f-91d0-s89t59d45321&format=json&language=en-us&aka=0&business=0&seasons=0&seasonYear=0&technical=0&filter=2&exactFilter=0&limit=5&forceYear=0&trailers=0&movieTrivia=0&awards=0&moviePhotos=0&movieVideos=0&actors=0&biography=0&uniqueName=0&filmography=0&bornAndDead=0&starSign=0&actorActress=0&actorTrivia=0&similarMovies=0&adultSearch=0&goofs=0"es=0&fullSize=0&companyCredits=0&callback=JSON_CALLBACK").success(function (response) {
- console.log(response);
- $scope.movies = response.data.movies;
- })
- }
- $scope.dateTime = new Date().getMinutes();
- // alert($scope.dateTime);
- document.getElementById("btnSearch").addEventListener('click', function SearchMovieByTitleDigest() {
- var title = $scope.searchByTitle;
- $scope.$watch("searchByTitle", function (newValue, oldValue) {
- $scope.searchByTitle = newValue;
- console.log("$scope.searchByTitle Called " + $scope.searchByTitle);
- alert($scope.searchByTitle);
- });
- //console.log(title);
- //alert(title);
- $http.jsonp("http://api.myapifilms.com/imdb/idIMDB?title=" + $scope.searchByTitle + "&token=5bf5tr54-203f-4a6f-91d0-s89t59d45321&format=json&language=en-us&aka=0&business=0&seasons=0&seasonYear=0&technical=0&filter=2&exactFilter=0&limit=5&forceYear=0&trailers=0&movieTrivia=0&awards=0&moviePhotos=0&movieVideos=0&actors=0&biography=0&uniqueName=0&filmography=0&bornAndDead=0&starSign=0&actorActress=0&actorTrivia=0&similarMovies=0&adultSearch=0&goofs=0"es=0&fullSize=0&companyCredits=0&callback=JSON_CALLBACK")
- .success(function (response) {
- $scope.movies = response.data.movies;
- $timeout(function () {
- $scope.$digest();
- }, 100);
- })
- });
- //document.getElementById("btnSearch").addEventListener('click', function () {
- // console.log("Seach Started");
- // alert("Seach Started");
- // $scope.dateTime = new Date().getMinutes();
- // $scope.$digest();
- // });
- }]);







Ravi KandelPosted Aug 14, 2016, 3:04 AM
Awesome
Bhavik PatelPosted Aug 2, 2016, 10:54 PM
Nice
Joginder BangerPosted Aug 2, 2016, 4:20 AM
Good one
Tarun DPosted Aug 2, 2016, 3:03 AM
Thanks for sharing..
Humayun Kabir MamunPosted Aug 1, 2016, 12:28 AM
Nice...
Bhavik PatelPosted Jul 31, 2016, 11:29 PM
Nicely explained
Vignesh ManiPosted Jul 30, 2016, 8:11 PM
Good one
Bikesh SrivastavaPosted Jul 30, 2016, 3:10 PM
Nice one