0

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

8
  • 1
    add the ngRoute to the controller as well. Possible link solution Commented Aug 21, 2018 at 9:12
  • @ ZombieChowder tx for response and I have tried this but same error Commented Aug 21, 2018 at 9:14
  • 1
    @Rushidave angular.js and angular-route.js files should have matching versions. Change 1.2.0rc1 to 1.6.9 Commented Aug 21, 2018 at 9:17
  • 1
    @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 Commented Aug 21, 2018 at 9:23
  • 1
    inconsistencies between modules, controllers and js includes is the source if your issue. Just double check everything and you should resolve this issue easily. Commented Aug 21, 2018 at 9:30

1 Answer 1

1

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> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.