我有一个 Rails 应用程序,使用 angularjs 进行客户端开发。我尝试加载位于 `app/assets/javascripts/templates/' 中的模板:
myApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/', {
templateUrl: '/index.html',
controller: 'MainController'
}).
otherwise({
redirectTo: '/'
});
}]);
但我总是收到错误消息:“错误:[$compile:tpload] 无法加载模板:/index.html”。
我试图将“模板”文件夹移出 javascripts - app/assets/templates,并通过将以下行添加到 config/application.rb 来将其添加到我的资产管道负载中:config.assets.paths << Rails.root.join("app","assets","templates")
在使用模板的完整路径之前,我一直收到相同的错误消息:templateUrl: '/assets/index.html',
.
为什么第一种方法还不够?angular-rails-templates gem 不应该在 app/assets/javascripts/templates 中寻找模板?
为什么我应该在我的 javascript 中使用资产的完整路径?