angular-rails-templates:找不到模板

ben*_*ams 2 ruby-on-rails angularjs angular-routing ngroute angularjs-templates

我有一个rails应用程序,使用angularjs进行客户端开发.我尝试加载位于`app/assets/javascripts/templates /'的模板:

myApp.config(['$routeProvider',
  function($routeProvider) {
    $routeProvider.
      when('/', {
        templateUrl: '/index.html',
        controller: 'MainController'
      }).
      otherwise({
        redirectTo: '/'
      });
  }]);
Run Code Online (Sandbox Code Playgroud)

但我总是收到一个错误:"错误:[$ compile:tpload]无法加载模板:/index.html".

我试图将"templates"文件夹移出javascripts - app/assets/templates,并通过在config/application.rb中添加以下行将其添加到我的资产管道加载中: config.assets.paths << Rails.root.join("app","assets","templates")

在我使用模板的完整路径之前,我一直收到相同的错误消息:templateUrl: '/assets/index.html',.

  1. 为什么第一种方法不够用?angular-rails-templates gem不应该在app/assets/javascripts/templates中查找模板?

  2. 我为什么要在javascript中使用资源的完整路径?

jcu*_*nod 8

我的问题是sprockets不兼容.版本2.1.3虽然有效但我把它放在我的Gemfile:

gem 'sprockets', '2.12.3'
Run Code Online (Sandbox Code Playgroud)

我跑了bundle update sprockets,它都是桃子.