RudziankoŇ≠ RudziankoŇ≠ - 1 year ago 133
Ajax Question

AngularJS: fetch json from server using AJAX

I am looking at this tutorial. And I have such code:

<!DOCTYPE html>
<html lang="en" ng-app="">
<meta charset="UTF-8">
<title>SPA book_store</title>
<script src=""></script>
<link rel="stylesheet" href="">
<script src=""></script>
<script src=""></script>

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
.then(function(response) {
$scope.books =;

<div ng-app="myApp" ng-controller="myCtrl">
<input id="filter_input" type="text" ng-model="nameText"/>
<li ng-repeat="book in books | filter:nameText | orderBy:'name'">
{{}} - {{book.price}}


is returning following




But I see in a browser networking that request wasn't fire. What have I done wrong?

Answer Source

Remove the ng-app="" from the html tag or provide the module name ng-app="MyApp".

Also remove one of the ng-app directives either from the the body tag or the html tag.

It is good practice to user the ng-app directive on the HTML tag if you are using just one angular app.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download