角轨的模板:模板未发现 [英] angular-rails-templates: templates are not found

查看:297
本文介绍了角轨的模板:模板未发现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Rails应用程序,使用angularjs为客户端的开发。我尝试加载位于`模板应用程序/资产/ Java脚本/模板/:

  myApp.config(['$ routeProvider',
  功能($ routeProvider){
    $ routeProvider。
      什么时候('/', {
        templateUrl:/index.html',
        控制器:'MainController
      })。
      除此以外({
        redirectTo:'/'
      });
  }]);

但我总是得到一个错误:错误:[$编译:tpload]无法加载模板:/index.htm」明明。

我想搬出去的JavaScript的模板文件夹 - 通过添加以下行的config / application.rb中的应用程序/资产/模板,将其添加到我的资产负载管道:配置.assets.paths<< Rails.root.join(应用程序,资产,模板)

我不断收到同样的错误消息,直到我用的完整路径模板: templateUrl:/assets/index.html,


  1. 为什么第一种方法是不够的?角护栏模板宝石不应该寻找在应用程序/资产/ Java脚本/模板模板?


  2. 为什么要使用的完整路径的资产,我的javascript里面呢?



解决方案

我的问题一直是链轮不兼容。 2.1.3版的作品,虽然所以我把这个在我的的Gemfile

 宝石链轮,2.12.3

和我跑了捆绑更新链轮,这一切都桃色的。

I have a rails application, using angularjs for the client side development. I try to load a template located in `app/assets/javascripts/templates/':

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

but I always get a error: "Error: [$compile:tpload] Failed to load template: /index.html".

I tried to move the "templates" folder out of the javascripts - app/assets/templates and to add it to my assets pipeline load by adding the following line to config/application.rb: config.assets.paths << Rails.root.join("app","assets","templates")

I keep getting the same error message until I use the full path to the template: templateUrl: '/assets/index.html',.

  1. Why the first method is not enough? the angular-rails-templates gem shouldn't look for templates in app/assets/javascripts/templates?

  2. Why should I use the full path to an assets inside my javascript?

解决方案

My problem has been a sprockets incompatibility. Version 2.1.3 works though so I put this in my Gemfile:

gem 'sprockets', '2.12.3'

And I ran bundle update sprockets and it's all peachy.

这篇关于角轨的模板:模板未发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆