所以,我正在尝试使用AngularJS中的模板文件夹,而不是通常在Rails中使用的“views”文件夹 .
当我用html编写所有东西时,事情很有效,但是如果我想用苗条编写东西,并且仍然使用AngularJS模板而不是rails视图呢?
不幸的是......它不太奏效 . 它在我的页面开头添加了这个,然后成功地将其余部分从slim转换为html:
Angular Rails Template // source: app/assets/templates/books/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****
') }]);
所以它很接近,但没有雪茄 . 我已经看到了其他的工作,包括进入你的配置文件夹在rails和添加文件等...但它们似乎没有工作 . 我应该在这看任何方向?我的主要目标是能够在AngularJS中使用“模板”(主要是因为我可以使用ui路由器),但能够用SLIM而不是html编写它们 .
编辑:嗯...刚刚重新启动我的服务器,现在一切正常 . 什么's really scary is that everything works without the ' angular rails templates'gem ...而且 config/initializers/angular_helper.rb
中没有任何特殊的配置文件,如下所示:#For Slim,还记得向Gemfile添加gem Rails.application.assets.register_engine('.slim', Slim::Template)
我所要做的就是在 ui-router
中调用 filename.html.slim
......一切正常 . 重新启动服务器我想是教训
很抱歉浪费Stackoverflow空间
1 回答
当您使用Angular Rails Template gem时,您必须加载模板
当你的路径是app / assets / templates / foo / bar / index.html时 .