How to set Pre selected data in dynamic select option in IONIC

拟墨画扇 提交于 2019-12-02 08:27:55

Firt, your JSON is not a array of objects. I dont know if work in a <select> by objects atributes... by my other answer you can do something like in below.

Try to use like that:

"Roles" : {
           [
              {code: 21, name: "Admin"},
              {code: 22, name: "Main Manager"}, 
              {code: 23, name: "Branch Manager"},
              {code: 24, name: "Side Manager"}
           ]
          }

So the atribute "code" will be my index to the select:

<select ng-options="role.name for role in Roles track by role.code">
        <option value="">They see me rollin</option>
</select>

What I do was use track by role.code, as you can watch in this video.

REMEMBER: If code reapet in the array of objects it will break the <select>.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!