Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Angular variable in Rails link_to

I'm using Angularjs in parts of my Rails app, which works great. But I'm wondering how to use an Angular value inside a link_to.

Here is my pseudo code:

%table          
  %tr{"ng-repeat" => "book in books"}
    %td
      {{book.title}}
    %td= link_to "Show", book_url({{book.id}})

This gives me an error:

syntax error, unexpected '}', expecting tASSOC

This could also have to do with HAML causing the error, but how can I send the ID in the link_to?

like image 932
John Avatar asked May 22 '13 14:05

John


1 Answers

This worked for me:

<li ng-repeat="deal in deals">
    <%= link_to 'show,'#','ng-href' => "#{deals_path()}/{{deal.id}}" %>
</li>
like image 155
dwaynemac Avatar answered Oct 13 '22 09:10

dwaynemac