1

I am getting the following error while loading the page using angular.js.

Error:

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.6/$injector/modulerr?p0=Channabasavashwara&…20at%20d%20(http%3A%2F%2Foditek.in%2FGofast%2Fjs%2Fangularjs.js%3A19%3A463)

I am explaining my code below.

loginRoute.js:

var Admin=angular.module('Channabasavashwara',['ngRoute']);
Admin.config(function($routeProvider){
    $routeProvider
    .when('/dashboard',{
        templateUrl: 'dashboardview/dashboard.html',
        controller: 'dashboardController'
    });
})

loginController.js:

var loginAdmin=angular.module('Channabasavashwara',[]);
loginAdmin.controller('loginController',function($scope,$http,$window){
    $scope.user_login=function(){
    if($scope.user_name==''){
        alert('user name filed should not keep blank');
    }else if($scope.user_pass==''){
        alert('password filed should not keep blank');
    }else{
        var userData={'user_name':$scope.user_name,'user_pass':$scope.user_pass};
        console.log('user',userData);
        $http({
            method: 'POST',
            url: "php/Login/login.php",
            data: userData,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        }).then(function successCallback(response){
            console.log('response',response);
            alert(response.data['msg']);
            location.href='dashboard/';
        },function errorCallback(response) {
            alert(response.data['msg']);
        });
    }
    }
});

If i am removing the loginRoute.js link from index page this error is not coming. But here imy requirement is user will forwarded to another(i.e-dashboard) page after successfull login.Please help me to resolve this error.

2
  • use this angular.module('Channabasavashwara').controller() Commented Oct 5, 2015 at 6:04
  • Have you included js file for ng-route module ? Commented Oct 5, 2015 at 6:34

1 Answer 1

1

You forgot to add require dependancy in controller to inject.

Replace loginAdmin.controller('loginController',function($scope,$http,$window){

To

loginAdmin.controller('loginController',['$scope','$http','$window',function($scope,$http,$window){

and replace var loginAdmin=angular.module('Channabasavashwara',[]);

to

var loginAdmin=angular.module('Channabasavashwara');

Sign up to request clarification or add additional context in comments.

6 Comments

@ Sarjan : I added as per you but still its throwing another error but 1st error has gone.Error-` errors.angularjs.org/1.4.6/ng/…`
Varity that you have added all js file in index.html...and check the updated answer
@ Sarjan : I updated as per you but still error was there.After removing '$scope','$http','$window' from line loginAdmin.controller('loginController','$scope','$http','$window',function($scope,$http,$window){ and made it to loginAdmin.controller('loginController',function($scope,$http,$window){ it worked properly.
@ Sarjan : another one problem it is not redirecting to dashboard page and showing error The requested URL /Gofast/dashboard was not found on this server.
@ Sarjan : No,If i am doing as per you after successfully login the url is becoming http://oditek.in/dashboard which is wrong,It should http://oditek.in/Gofast/dashboard like this.Here i need when user will logged in he will move to another page.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.