I am using a nested form and AngularJS, and I have this on my code.
#app/view/customer_templates/edit.html.erb
<%= f.simple_fields_for :customer_template, @customer.customer_template.build, child_index: '{{$index}}' do |t| %>
<%= t.select :field_type_id, options_from_collection_for_select(FieldType.all, :id, :name, '{{customer_template.field_type_id}}') %>
<% end %>
My select is working but not getting the current data of field_type_id.
{{customer_template.field_type_id}} from angular, is returning the right data but it is a string, when I tried to convert this to integer like {{customer_template.field_type_id}}.to_i, the result is 0. I tried also to pass this to a variable and converted it, but I am getting same result.
I also tried this {{parseInt(customer_template.field_type_id)}}, and in my angularjs $scope.parseInt = parseInt but have no luck.
This is my problem, below.

I must have 1-Checkbox, 2-Dropdown (Yes/No), and 2-Textbox, can you help me with this? I am a noob in AngularJS. My only problem is the value, I will put inside options_from_collection_for_select. If I can put an integer, it is working.
Have you tried the short hand conversion in javascript?
{{+customer_template.field_type_id}}
And in your controller like this:
$scope.parseInt = +parseInt;
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