Search code examples
ruby-on-railsangularjstemplatespartial-viewsangularjs-ng-include

Angulars + Rails: ngInclude directive not working


I'm working on a rails + angularjs app.

Here is my file structure:

app/
assets/
    javascript/
    templates/
       home.html
       partial.html

Inside the home.html.erb file I want to include the partial.html.erb file.

home.html.erb

<ng-include src="'partial.html'"></ng-include>

I also tried

<ng-include src="'<%= asset_path('partial.html') %>'"></ng-include>

But still doesn't work... Thanks for your help


Solution

  • Setup gem "angular-rails-templates"

    It will automaticaly compile your templates into javascript, and make them available to angular. After that you may use ng-include as usual.

    <ng-include src="'templates/partial.tpl.html'"></ng-include>