14
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!

Charles
  • 50,943
  • 13
  • 104
  • 142
natecraft1
  • 2,737
  • 9
  • 36
  • 56

3 Answers3

27

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

Andyrooger
  • 6,748
  • 1
  • 43
  • 44
  • hi! no i didn't know that was required. I just got the route.min.js from here http://code.angularjs.org/1.2.0rc1/ and put it in my assets/javascripts file and put this in my application.html.erb but it gave me errors like TypeError: Cannot read property 'copy' of undefined angular-route.js:7 Error: Unknown provider: $sceProvider <- $sce <- $route <- ngViewDire – natecraft1 Oct 17 '13 at 01:25
  • You need to tell it that it's JS. So try: – KayakDave Oct 17 '13 at 01:31
  • What version of main angular.js file do you have? – Andyrooger Oct 17 '13 at 08:23
  • im using this gem 'angularjs-rails' – natecraft1 Oct 17 '13 at 22:54
  • In that case, it looks like you should be including `angular-route` with something like `//= require unstable/angular-route` in your gemfile. However, if you are not using unstable angular then I would expect @BKM is correct and you probably don't need the module. – Andyrooger Oct 18 '13 at 00:27
  • Refer this page https://github.com/angular/bower-angular-route to install ngRoute. – Evan Hu Jan 17 '15 at 07:55
2

Add angular-route into application.js like

in /app/assets/javascripts/application.js

//= require angular
//= require angular-resource
//= require angular-route
Tarun Garg
  • 717
  • 6
  • 19
-1

Remove ngRoute from our dependency injection as you are already injecting routeProvider in config

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