0
votes

I have used angular and angular routing

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>

In error this file Indexcontroller.js

var app = angular.module('myapp', ['ngRoute']);
app.controller('myCtrl', ['$scope']);

app.config(["$routeProvider", function($routeProvider) {
  $routeProvider
    .when('/ui-login', {
      templateUrl: 'ui-login.html',
      controller: 'loginController'
    })
    .otherwise({
      redirectTo: '/ui-login'
    });
}]);
app.controller('loginController', function($scope) {
  //Controller Here

  $scope.submit = function() {
    console.log("hi i m coming");
  }
  console.log("in controller");
});

Error:

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.6.9/$injector/modulerr?p0=myApp&p1=Error%3A%2…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.6.9%2Fangular.min.js%3A22%3A332)

Output: enter image description here

1
add the ngRoute to the controller as well. Possible link solution - ZombieChowder
@ ZombieChowder tx for response and I have tried this but same error - Rushi dave
@Rushidave angular.js and angular-route.js files should have matching versions. Change 1.2.0rc1 to 1.6.9 - Aleksey Solovey
@Rushidave you should be more specific. Your error says myApp, whereas your module is named myapp. You don't pass a controller function in here: app.controller('myCtrl', ['$scope']);. And for better error logs you can change .min.js to .js - Aleksey Solovey
inconsistencies between modules, controllers and js includes is the source if your issue. Just double check everything and you should resolve this issue easily. - ZombieChowder

1 Answers

1
votes

I solved the issue

I have to put angular.min.js before angular-route.min.js and than it's solved

 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-route.min.js"></script>
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>

order matters here

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-route.min.js"></script>