简体   繁体   中英

Angularjs error issue

I am getting an error TypeError: Cannot read property 'get' of undefined.i have tried so many ways but not able to solve.

mycode is login.controller.js

(function () {
    'use strict';

    angular
        .module('app')
        .controller('LoginController', LoginController);

    LoginController.$inject = ['$location', 'AuthenticationService', 'FlashService'];
    function LoginController($location, AuthenticationService, FlashService) {
        var vm = this;

        vm.login = login;

        (function initController() {
            // reset login status
            AuthenticationService.ClearCredentials();
        })();

        function login() {
     var  usename=vm.username;
     var   password=vm.password;

            vm.dataLoading = true;

       $http.get('http://localhost:8080/ProjectManagement/REST/Login/Check?usename='+usename+'&password='+password+'').success(function(data, status, headers, config,response){

              if (data=="0")
                  {

                  }
              else
                  {


                  }


        }).error(function(data, status, headers, config,response) {


        });

        };
    }

})();

You missed to add $http dependency inside you controller, make sure all the dependencies are injected before using it.

Code

LoginController.$inject = ['$location', 'AuthenticationService', 'FlashService', '$http'];
function LoginController($location, AuthenticationService, FlashService, $http) {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM