Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trouble using angularjs with slim in a rails project

I've finally decided to give angularjs a whirl and i'm running into some early trouble.

I'm using Rails 3.2 and the Slim template gem for the view.

I'm just trying the example from the angularjs site here: http://angularjs.org/#todo-html

Here's the relevant bit:

 <div ng-controller="TodoCtrl">
   <span>{{remaining()}} of {{todos.length}} remaining</span>

Which in slim would be something like:

div(ng-controller="TodoCtrl")
  span {{remaining()}} of {{todos.length}} remaining

The problem is Slim just prints:

{{remaining()}} of {{todos.length}} remaining

literally as a string.

Anyone able to get Slim and Angular to play together?

like image 731
jacklin Avatar asked Apr 10 '13 04:04

jacklin


1 Answers

I finally got it to work.

I had to go into my layout and do this:

html(ng-app='')

You can probably add that to a div on the particular page also.

div(ng-app='')
  div(ng-controller="TodoCtrl")
    span {{remaining()}} of {{todos.length}} remaining

Hopefully this helps someone. It took me a bit to figure out.

like image 67
jacklin Avatar answered Sep 22 '22 02:09

jacklin