Using angular.js often items like ng-click or ng-model are written directly in the html form element like so....
<input type="text" ng-model="name">
How would I do that with rails? As rails uses embedded ruby and generates the html....
<%= form_for(@user) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
How would I add the ng-model to <%= f.text_field :name %> ?
Ideally, you don't want to be mixing embedded ruby interpolation and Angular's interpolation. It's better to have ruby asynchronously serve JSON to Angular, and let Angular take care of filling in the data on the client side.
Try this, when it's a hyphen separated word, you need to put within a hash notation.
f.text_field :name, :ng => {:model => "name"}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With