3
votes

this is my Index.html code

      <!DOCTYPE html>
     <html ng-app="demo">        
  <head>
     <title></title>   
     <script src="scripts/angular.min.js"></script>
     <script src="scripts/angular-route.min.js"></script>
     <script src="scripts/CustomAngularJavaScript.js"></script>
     <link href="StyleSheet1.css" rel="stylesheet" />
    <base href="/">   

 </head>
 <body>
      <table>
         <tr><td colspan="2" class="header">
             <h1>Web Portal</h1>
             </td></tr>
          <tr><td class="leftmenu">     
             <a href="Home">Home</a>
                <a href="Courses">Courses</a>
                 <a href="Students">Student</a>

                </td>
                    <td class="mainContent"><ng-view></ng-view></td>
                </tr>
                <tr>
                   <td colspan="2" class="footer"><b>Copyright</b></td>
              </tr>
      </table>
 </body>
 </html>

second one js code

        /// <reference path="angular.min.js" />






var angualarModule = angular.module("demo", ["ngRoute"]);    

 angualarModule.config(["$routeProvider","$locationprovider",function     ($routeProvider,$locationprovider) {
        $routeProvider.   
          when('/Home', {
             templateUrl: 'Templates/Home.html',   
            controller: 'HomeController'
         }).
          when('/Courses', {    
             templateUrl: 'Templates/Courses.html',
            controller: 'CourseController'
    }).
    when('/Students', {
        templateUrl: 'Templates/Students.html',
        controller: 'StudentsController'
    })


    $locationprovider.html5mode(true);  
}])

angualarModule.controller("HomeController", function ($scope) {
    $scope.message = "Home Page" ;    

})
angualarModule.controller("CourseController", function ($scope) {
    $scope.courses = ["C Sharp","Angular","MVC"] ;

})
angualarModule.controller("StudentsController", function ($scope) {
    $http.post('Service.asmx/getUser').then(function (res) {
     $scope.students = res.data;
});     


})

throwing error "angular.min.js:6Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=demo&p1=Error%3A%20…0g%20(http%3A%2F%2Flocalhost%3A61022%2Fscripts%2Fangular.min.js%3A39%3A319)"

Can anyone please tell me what am doing wrong, the error being showed only when i add "$locationprovider" in angular module

5
If you modify the code, pls modify it in the question as wellMakarov Sergey
the changes that i have done but still facing same error....plz helpRishabhT

5 Answers

0
votes

Because it is $locationProvider (with an uppercase) :)

And for the minification you need inject your provider like this

angualarModule.controller("HomeController", ['$scope',function ($scope) {
    $scope.message = "Home Page" ;    

}]);
0
votes

Try $locationProvider. Looks it's a spelling issue.

0
votes

you mispelled it, it's $locationProvider

https://docs.angularjs.org/api/ng/provider/$locationProvider

0
votes
  var angualarModule = angular.module("demo", ["ngRoute"]);    

     angualarModule.config(["$routeProvider","$locationProvider",function     ($routeProvider,$locationProvider) {
    $routeProvider.   
      when('/Home', {
         templateUrl: 'Templates/Home.html',   
        controller: 'HomeController'
     }).
      when('/Courses', {    
         templateUrl: 'Templates/Courses.html',
        controller: 'CourseController'
    }).
when('/Students', {
    templateUrl: 'Templates/Students.html',
    controller: 'StudentsController'
})


$locationProvider.html5mode(true);  
 }])

angualarModule.controller("HomeController", function ($scope) {
$scope.message = "Home Page" ;    

 })
     angualarModule.controller("CourseController", function ($scope) {
    $scope.courses = ["C Sharp","Angular","MVC"] ;

})
 angualarModule.controller("StudentsController", function ($scope) {
     $http.post('Service.asmx/getUser').then(function (res) {
      $scope.students = res.data;
 });     


 })
0
votes

Here are the following steps I took to resolve this issue,
1. Order of js file reference changed,
2. Null value for a variable