7
var hsbc = angular.module('hsbc',['ngResource','ngRoute']);

hsbc.config(['$routeProvider','$locationProvider', function ($routeProvider, $locationProvider){   

//console.log('config part working'); 
$routeProvider
    .when('/login', {
        controller: 'hsbccontroller',
        templateUrl: 'modules/authentication/views/login.html',
        hideMenus: true
    })
    .when('/gloabltranfer', {
        controller: 'hsbccontroller',
        templateUrl: 'modules/home/views/gloabltranfer.html'
    })
    .when('/tranferReq', {
        controller: 'hsbccontroller',
        templateUrl: 'modules/home/views/TransferRquest.html'
    })
    .when('/reviewdetail', {
        controller: 'hsbccontroller',
        templateUrl: 'modules/home/views/Reviewdetails.html'
    })
    .when('/confirmdetail', {
        controller: 'hsbccontroller',
        templateUrl: 'modules/home/views/confirmdetails.html'
    })

    .when('/', {
        controller: 'hsbccontroller',
        templateUrl: 'modules/authentication/views/login.html'
    })

    .otherwise({ redirectTo: '/login' });

}]).controller('hsbccontroller', ['$scope','$http','$resource', function($scope,$resource,$http){

    //console.log('controller part working'); 
    $http.get('http://localhost:8080/1/').success(function(data) {
        alert(data);
        $scope.greeting = data;
    });

}]);
Barry
  • 3,303
  • 7
  • 23
  • 42
Rajesh Kumar
  • 153
  • 2
  • 4
  • 13
  • 6
    Your controller's parameters are not in the same order that they were declared using the array notation. Change the position of `$resource` and `$http`. – Tom Arad Apr 26 '15 at 14:19
  • 1
    it should be .controller('hsbccontroller', ['$scope','$http','$resource', function($scope,$http, $resource){ – Kop4lyf Apr 26 '15 at 14:20
  • 1
    Cool, Thanks its working buddy. Quite new to working in angularJs with Rest API. thanks a lot. – Rajesh Kumar Apr 26 '15 at 14:23

1 Answers1

28

You need to change the positions of $http and $resource.

How angularJS works is, (if defined in this way), angular tries to match the strings provide to the arguments of the function, so that it knows which argument is what. This is basically for the purpose of minification, which will actually change the variables like illustrated below.:

.controller('hsbccontroller', ['$scope','$http','$resource', function(a,b,c){

    //console.log('controller part working'); 
a.get('http://localhost:8080/1/').success(function(data) {
    alert(data);
        $scope.greeting = data;
    });
}]);

so here, angularjs knows that:

a means $scope,

b is $http,

and c is $resource.

In your case, it was actually trying "$resource.get" and hence giving you the error. Further reading check the note on minification on the given doc page: https://docs.angularjs.org/tutorial/step_05

Kop4lyf
  • 4,520
  • 1
  • 25
  • 31