-1

im building a Rails app and use angular-rails-templates gem. Im trying to load the template using ng-include and it's not working. Here's my application.js :

//= require jquery
//= require jquery_ujs
//= require angular
//= require angular-rails-templates
//= require lodash
//= require_tree ../templates
//= require_tree .

The template file is located in assets/templates/person.html The index.html.erb file which have ng-include (Only the part that have it) :

<li ng-repeat="item in dirList.list | filter:search">
    <ng-include src="'person.html'"></ng-include>
</li>

The js file (only the first part) :

angular.module('directoryApp', ['templates'])
    .controller('directoryController', function() {

        var dirList = this;

        dirList.toggle = true;

What might be the problem? The rest of the app is working! What am I doing wrong? Is there a better way to use angular templates inside rails?

THpubs
  • 7,804
  • 16
  • 68
  • 143

2 Answers2

1

Downgrade 'sprockets' gem to '2.x.x' version (e.g. 2.12.3) manually in the Gemfile, if you are using 'angular-rails-templates' 0.2.0 version or earlier because it currently has a dependency on 'sprockets' 2.x.

Besides that, be sure to put

config.angular_templates.ignore_prefix = %w(templates/)

in 'config/application.rb' file.

Nikola Todorovic
  • 300
  • 3
  • 12
1

Ran into the same issue, ultimately realized the angular syntax required an element when using the ng-include statement. The following worked for me.

<li ng-repeat="item in dirList.list | filter:search">
    <div ng-include="'person.html'"></div>
</li>
Cory
  • 21
  • 2