Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: No module: ngRoute when trying to implement routing in angularjs

app = angular.module("dithat", ["ngRoute", "ngResource", 'ng-rails-csrf']);
  app.config(['$routeProvider',
  function($routeProvider) {
  $routeProvider.
  when('/', {
    templateUrl: 'app/views/layouts/_user_page.html',
    controller: 'accomplishmentController'
  });
}]);

Am I missing something? Thanks!

like image 818
natecraft1 Avatar asked Oct 17 '13 01:10

natecraft1


People also ask

What is ngRoute AngularJS?

AngularJS ngRoute module provides routing, deep linking services and directives for angular applications. We have to download angular-route. js script that contains the ngRoute module from AngularJS official website to use the routing feature. You can also use the CDN in your application to include this file.

What is the difference between ngRoute and UI-router?

The ui-router is effective for the larger application because it allows nested-views and multiple named-views, it helps to inherit pages from other sections. In the ngRoute have to change all the links manually that will be time-consuming for the larger applications, but smaller application nrRoute will perform faster.

How do we set a default route in $routeProvider?

Creating a Default Route in AngularJS The below syntax just simply means to redirect to a different page if any of the existing routes don't match. otherwise ({ redirectTo: 'page' }); Let's use the same example above and add a default route to our $routeProvider service. function($routeProvider){ $routeProvider.

What is use of $routeProvider in AngularJS?

We use $routeProvider to configure the routes. The config() takes a function that takes the $routeProvider as a parameter and the routing configuration goes inside the function. The $routeProvider is a simple API that accepts either when() or otherwise() method.


1 Answers

Have you included the angular-route.js file in your page? And are you using angular 1.2.0 - the module doesn't seem to exist prior to this.

See http://docs.angularjs.org/api/ngRoute

like image 172
Andyrooger Avatar answered Oct 18 '22 16:10

Andyrooger