试图用“角Rails的模板”宝石 [英] Trying to Use 'Angular Rails Templates' gem

查看:179
本文介绍了试图用“角Rails的模板”宝石的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我想使用AngularJS,而不是你通常会在Rails中使用若干意见文件夹中的模板文件夹。

so, I'm trying to use the templates folder in AngularJS instead of the 'views' folders that you'd normally use in Rails.

物联网工作的伟大,当我写HTML的一切,但如果我想要写在纤细的东西,仍然AngularJS模板的工作,而不是轨道的看法?

Things work great when I write everything in html, but what if I want to write things in slim, and still work with AngularJS templates, instead of rails Views?

答案:角轨模板

不幸的是......这完全不是那么回事。它增加了这个在我的网页开始,它成功地使纤细的休息成HTML之前:

Unfortunately... it doesn't quite work. It adds this at the beginning of my page before it successfully renders the rest from slim into html:

角Rails的模板//来源:应用程序/资产/模板/书籍/ indexx.html.slim

angular.module("templates").run(["$templateCache", function($templateCache) { $templateCache.put("books/indexx.html", '

  //the rest of my webpage, beautifully rendered from slim to html****


') }]); 

所以这是接近,但没有雪茄。我已经看到了这个其他变通,涉及进入你的config文件夹中轨和添加文件等等......但没有人似乎工作。我要在这里寻找任何方向?我的主要目标只是能在AngularJS使用'模板'(主要是这样我就可以使用UI路由器),但能够将它们写在SLIM而不是HTML。

So it's close, but no cigar. I've seen other work arounds for this, involving going into your config folder in rails and adding files and so on... but none of them seemed to work. Any direction I should be looking here? My main goal is just be able to use 'templates' in AngularJS (mainly so I can use the ui router) but be able to write them in SLIM instead of html.

编辑:嗯...只是重新启动我的服务器,现在一切正常。什么是真正可怕的是,一切作品,未经角轨模板宝石......也没有任何特殊的配置文件中的配置/初始化/ angular_helper.rb ,看起来像: #对于苗条,记得也给宝石增加的Gemfile Rails.application.assets.register_engine('苗条',修身::模板)

Hmm... just restarted my server and now everything works. What's really scary is that everything works without the 'angular rails templates' gem... and also without any special config file in config/initializers/angular_helper.rb that looks like: # For Slim, remember also to add gem to Gemfile Rails.application.assets.register_engine('.slim', Slim::Template)

我所要做的就是在我的 UI路由器调用 filename.html.slim ...和一切正常。 RESTART我想在服务器的教训

All I had to do was call the filename.html.slim in my ui-router...and everything works. RESTART THE SERVER I guess is the lesson

抱歉浪费这个空间#1

Sorry for wasting Stackoverflow space with this

推荐答案

当您使用Rails的角度宝石模板,您对

When you use Angular Rails Template gem, you have to load your templates over

    templateURL: 'foo/bar/index.html'

在路径是应用程序/资产/模板/富/酒吧/ index.html的。

when you path is app/assets/templates/foo/bar/index.html.

这篇关于试图用“角Rails的模板”宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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