导轨erb中的Angular Js花括号

时间:2014-04-15 13:18:43

标签: ruby-on-rails angularjs erb

是否有人知道是否可以渲染角度js花括号类型{{}} 在ERB中作为参数。

例如。

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

1 个答案:

答案 0 :(得分:1)

取自here的示例:

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

另请参阅本教程:http://blog.berylliumwork.com/2013/03/best-practice-of-using-angularjs-with.html

你可以看到这个例子:

<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>