3

Code in html.haml in Rails using AngularJS

%table
  %tbody{:"ng-init" => "my_model=#{@current_user_things.to_json}"}
    %tr{:"ng-repeat" => "row in my_model"}
      %td
        %a{:href => "{{row.permalink}}"}
          {{row.name}}

I am trying to replace what was originally a link_to in Rails that linked to row's page to it's equivalent using AngularJS. As I am providing AngularJS a template to repeat with, I now need to generate the link on the client side. Is there a way to do that easily?

I realise I can simply go %a{:href => "http://blah.com/rows/{{row.permalink}}"} but I would prefer a more elegant solution as the host can change.

1 Answer 1

1

I guess I could fix it like this:

%a{:href => "#{url_for(:action => 'index')}/{{row.permalink}}"}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.