Error ngRoute is not available
Asked Answered
A

2

0

there is my error in console

Error: [$injector:nomod] Module 'ngRoute' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

this is my index.html header :

    <script src="scripts/jquery-2.0.3.min.js" type="text/javascript"></script>
    <script src="scripts/libs/bootstrap.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js" type="text/javascript"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-route.js" type="javascript"></script>

    <script src="scripts/app.js" type="text/javascript"></script>
</head>

this is my app.js :

var app = angular.module('myapp', ['ngRoute']);

app.config(function($routeProvider){
$routeProvider
    .when('/queueManager', {
        templateUrl: '/templates/page/queueManager.html',
        controller: 'QCtrl'
    });
});

app.controller('QCtrl',['$http','$interval','$scope', function($http, $interval,$scope){
  this.queues = queue;
  var store = this;
  store.queues = [];
  var queue = [];

  $http.get('/queue/info').success(function(data) {
    store.queues = data;
  });
});

And this is my routes.js :

angular.module("myapp", ['ngRoute'])
.config(function($routeProvider){
    $routeProvider.when('/queueManager', {
        templateUrl: '/templates/page/queueManager.html'
    })
});

In dev tools from chrome, files appears as loaded, and it seems that i spelled it right... An I still get the same error as mentioned before. Every time i search on stackoverflow, it's the same answer check if you added it in your html... Have you some solution about my problem ?

Edit : Added app.config in app.js and changed routes module name to my app. And added edit

Thank you

Arty answered 26/2, 2015 at 16:28 Comment(2)
When are you loading routes.js, it's not shown above. Also, currently you can't keep calling angular.module("myapp", ['ngRoute']) as it redefines the modules and doesn't get the existing module. This is due to be fixed pretty soon, but not sure if it's in 1.3.14 (I think it will give an error about redefinition when that fix goes in).Sarpedon
I load routes.js just after app.js load. So i just should remove the ".config(....)" part ?Arty
A
0

I finally found my mistake....

My script type was "javascript" and not "text/javascript". Best mistake ever ...

Thanks for your answer by the way.

Arty answered 27/2, 2015 at 9:0 Comment(0)
F
0

You need to add your "AchApp" module as a dependency of the 'myapp' module.

So your app.js would look like:

var app = angular.module('myapp', ['ngRoute', "AchApp"]);

app.controller('QCtrl',['$http','$interval','$scope', function($http, $interval,$scope){
  this.queues = queue;
  var store = this;
  store.queues = [];
  var queue = [];

  $http.get('/queue/info').success(function(data) {
    store.queues = data;
  });
});
Furfural answered 26/2, 2015 at 16:32 Comment(0)
A
0

I finally found my mistake....

My script type was "javascript" and not "text/javascript". Best mistake ever ...

Thanks for your answer by the way.

Arty answered 27/2, 2015 at 9:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.