【发布时间】:2014-08-19 09:33:09
【问题描述】:
我在#edit 操作中有simple_form_for @tag,其中一个字段是
<%= f.input :color, collection: %(red green blue), input_html: {ng_model: 'colorBoxValue'} %>.
不幸的是,表单呈现后ng-model ColorBoxValue 是undefined。在我选择任何选项后,ng-model 正在正确设置。
我想要实现的是在选择任何选项之前正确设置ng-model ColorBoxValue(但请记住simple_form_for @tag 在#edit 操作中,因此@tag 具有价值(其中之一:红色/绿色/蓝色)来自数据库,所以我不能在静态值上硬编码ng-init...)。它应该得到来自数据库的selected 项目
有什么想法吗?
【问题讨论】:
标签: ruby-on-rails angularjs forms ruby-on-rails-4 simple-form