Prash Prash - 1 year ago 41
AngularJS Question

Cannot access http json service in angular js

I am new to angularjs and I want to know why it isn't working.

The code has a flaw and am not sure about the same.

Thinking from java perspective,httpController defined has nested function defined inside.

Here it is my code


<!DOCTYPE html>
<html >

<script src=""></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>

<div ng-app="myapp" ng-controller="HelloController">
<div ng-app="httpService" ng-controller="httpController">



var app = angular.module("myapp", []);
app.controller("HelloController", function($scope) {
$scope.message = "Hello, AngularJS";

var httpApp=angular.module("httpService",[]);


var onUserComplete=function(response){




Only one ng-app will be automatically bootstrapped on your page. That's why if you remove the first ngApp directive, the second one will work.

var httpApp = angular.module("httpService", []);

httpApp.controller("httpController", function($scope, $http) {

  var onUserComplete = function(response) {
    $scope.user =;

<script src=""></script>

<div ng-app="httpService" ng-controller="httpController">
  <div>FirstName: {{}}</div>

NOTE: You have a typo in your callback, remove ""s around your Also, since you are using Angular 1.5.6, you don't need to specify dependencies/inject your $http service to make your code work.