user3472404
user3472404

Reputation: 61

Angular Js curly braces in rails erb

Does anyone know if it is possible to render angular js curly braces type {{ }} in ERB as parameters.

eg.

 <=home_url( {{code.id}}, @code)/>

Upvotes: 4

Views: 2336

Answers (1)

Paulo Fidalgo
Paulo Fidalgo

Reputation: 22311

Taken from the example from here:

<div>
  <label>Name:</label>
  <input type="text" ng-model="yourName" placeholder="Enter a name here">
  <hr>
  <h1>Hello {{yourName}}!</h1>
</div>

Also check this tutorial: http://blog.berylliumwork.com/2013/03/best-practice-of-using-angularjs-with.html

where you can see this example:

<div data-ng-init='mailbox.selected = "<%= @current_page %>"'>
<ul class="nav nav-tabs">
  <li data-ng-class='{active: (mailbox.selected == "inbox")}'>
    <%= link_to mails_inbox_path, 'Inbox' %>
  </li>
  <li data-ng-class='{active: (mailbox.selected == "outbox")}'>
    <%= link_to mails_outbox_path, 'Outbox' %>
  </li>
  <li data-ng-class='{active: (mailbox.selected == "draft")}'>
    <%= link_to mails_draft_path, 'Draft' %>
  </li>
</ul>
</div>

Upvotes: 1

Related Questions