我正在开发一个 Rails + AngularJS 应用程序。
这是我的文件结构:
app/
assets/
javascript/
templates/
home.html
partial.html
在 home.html.erb 文件中,我想包含partial.html.erb 文件。
home.html.erb
<ng-include src="'partial.html'"></ng-include>
我也尝试过
<ng-include src="'<%= asset_path('partial.html') %>'"></ng-include>
但还是不行...谢谢你的帮助
最佳答案
Setup gem "angular-rails-templates"
它会自动将您的模板编译为 JavaScript,并使它们可供 Angular 使用。之后你就可以像往常一样使用 ng-include 了。
<ng-include src="'templates/partial.tpl.html'"></ng-include>
关于ruby-on-rails - Angular + rails : ngInclude directive not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26330223/