我似乎无法让它发挥作用。所以我有一堆类型的电影,我希望检查它们是否是用户数据库中的类型。这是我的代码
%section(ng-controller="UserCtrl" ng-init="user_genres=#{preferred_genres}")
%ul
%li(ng:repeat="genre in preferred_genres")
%input(type = "checkbox" ng:model="preferred_genres[genre]" id="genre-{{$index + 1}}" ng-checked="user_genres['{{genre}}']")
%label{:for => "genre-{{$index + 1}}"} {{genre}}
这是#{preferred_genres}
来自haml
{"Action & Adventure":true,"Animation":true,"Art House & International":true,"Classics":true,"Comedy":true,"Documentary":true,"Drama":true,"Horror":true,"Kids & Family":true,"Musical & Performing Arts":true,"Mystery & Suspense":true,"Romance":true,"Science Fiction & Fantasy":true,"Special Interest":true,"Sports & Fitness":true,"Television":true,"Western":true}
所以这意味着应该检查每个复选框。但是当我加载页面时没有选中复选框。但是,如果我硬编码ng-checked
成这样的东西,它就可以工作。
ng-checked="user_genres['Western']"
这真的很奇怪。请帮忙。