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

后端 未结 3 453
无人及你
无人及你 2021-01-11 10:48
app = angular.module(\"dithat\", [\"ngRoute\", \"ngResource\", \'ng-rails-csrf\']);
  app.config([\'$routeProvider\',
  function($routeProvider) {
  $routeProvider.
         


        
相关标签:
3条回答
  • 2021-01-11 11:17

    Add angular-route into application.js like

    in /app/assets/javascripts/application.js

    //= require angular
    //= require angular-resource
    //= require angular-route
    
    0 讨论(0)
  • 2021-01-11 11:35

    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

    0 讨论(0)
  • 2021-01-11 11:35

    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'
    });
    }]);
    
    0 讨论(0)
提交回复
热议问题