1

//show movie list 100

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Movie search App</title>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script type="text/javascript" src="controller.js"></script>

</head>
<body ng-app="myApp">

<div ng-controller="movies">

 <ul>
     <h1>IMDB 100 Movies</h1>

     <li ng-repeat="movie in movies">

      {{ movie.title }}



     </li>


 </ul>

    enter code here

</div>

</body>
</html>

//json file

{
    "records":

[

  {
        "title": "The Shawshank Redemption",
        "rank": "1",
        "id": "tt0111161"
    },
    {
        "title": "The Godfather",
        "rank": "2",
        "id": "tt0068646"
    },

// controller.js

var app=angular.module('myApp',[]);

app.controller('movies', function ($scope,$http) {

    $http.get('localhost/SPA/movies.json');

    .success(function(responce))

    {

         $scope.movies=responce.records; 

    }

});
3
  • 1
    get rid of the semicolon after the get Commented May 26, 2017 at 14:51
  • 1
    And don't use success() which is deprecated since 1.4 or 1.5, and doesn't exist anymore in 1.6. Use then(). Also, the correct spelling is response, not responce. Commented May 26, 2017 at 14:54
  • Change $http.get('localhost/SPA/movies.json'); to $http.get('localhost/SPA/movies.json') i.e, remove semicolon. $http returns promise and on that only you can use success function but by placing ; you are terminating the line Commented May 26, 2017 at 14:59

2 Answers 2

3

Remove ; from this line:

$http.get('localhost/SPA/movies.json');
Sign up to request clarification or add additional context in comments.

Comments

0

Change your controller.js to:

var app=angular.module('myApp',[]);

app.controller('movies', function ($scope,$http) {
    $http.get('localhost/SPA/movies.json').success(function(responce) {
         $scope.movies=responce.records; 
    });

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.