{"action":"created","issue":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima/issues/701","labels_url":"https://api.github.com/repos/IMA-WorldHealth/bhima/issues/701/labels{/name}","comments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima/issues/701/comments","events_url":"https://api.github.com/repos/IMA-WorldHealth/bhima/issues/701/events","html_url":"https://github.com/IMA-WorldHealth/bhima/issues/701","id":105031338,"number":701,"title":"Use ng-options for <select> elements","user":{"login":"jniles","id":896472,"avatar_url":"https://avatars.githubusercontent.com/u/896472?v=3","gravatar_id":"","url":"https://api.github.com/users/jniles","html_url":"https://github.com/jniles","followers_url":"https://api.github.com/users/jniles/followers","following_url":"https://api.github.com/users/jniles/following{/other_user}","gists_url":"https://api.github.com/users/jniles/gists{/gist_id}","starred_url":"https://api.github.com/users/jniles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jniles/subscriptions","organizations_url":"https://api.github.com/users/jniles/orgs","repos_url":"https://api.github.com/users/jniles/repos","events_url":"https://api.github.com/users/jniles/events{/privacy}","received_events_url":"https://api.github.com/users/jniles/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima/labels/best%20practice","name":"best practice","color":"fad8c7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-05T15:04:43Z","updated_at":"2015-12-13T20:55:52Z","closed_at":"2015-12-13T20:55:52Z","body":"In quite a few places, we have code that looks like this:\r\n```html\r\n<select>\r\n  <option ng-repeat=\"i in list\" ng-value=\"\" ng-selected=\"\">{{ i }}</option>\r\n</select>\r\n```\r\n\r\n[Here](https://github.com/IMA-WorldHealth/bhima/blob/master/client/src/partials/inventory/groups/groups.html#L101) [are](https://github.com/IMA-WorldHealth/bhima/blob/master/client/src/partials/reports_proposed/grand_livre/grand_livre.html#L31) [some](https://github.com/IMA-WorldHealth/bhima/blob/master/client/src/partials/creditor/group/creditor_group.html#L74) [places](https://github.com/IMA-WorldHealth/bhima/blob/master/client/src/partials/debtor/debtor_group.html#L94) [where]() [this pattern](https://github.com/IMA-WorldHealth/bhima/blob/master/client/src/partials/reports/operating_account/operating_account.html#L18) [is used](https://github.com/IMA-WorldHealth/bhima/blob/master/client/src/partials/reference/reference.html#L106).\r\n\r\nUsing `ng-repeat` on the `<select>` makes the ng-model bind a string, which requires extra work on the programmer's part to figure out what the model was actually supposed to be bound to.\r\n\r\nWe should really try to avoid using this pattern in the future.  As part of our refactor towards the end of the year, we should ensure that all these elements are changed out for `ng-option`s.\r\n\r\n[According to the angular documentation](https://docs.angularjs.org/api/ng/directive/select):\r\n\r\n> In many cases, ngRepeat can be used on <option> elements instead of ngOptions to achieve a similar result.  However, ngOptions provides some benefits, such as more flexibility in how the <select>'s model is assigned via the select as part of the comprehension expression, and additionally in reducing memory and increasing speed by not creating a new scope for each repeated instance.\r\n"},"comment":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima/issues/comments/164297157","html_url":"https://github.com/IMA-WorldHealth/bhima/issues/701#issuecomment-164297157","issue_url":"https://api.github.com/repos/IMA-WorldHealth/bhima/issues/701","id":164297157,"user":{"login":"jniles","id":896472,"avatar_url":"https://avatars.githubusercontent.com/u/896472?v=3","gravatar_id":"","url":"https://api.github.com/users/jniles","html_url":"https://github.com/jniles","followers_url":"https://api.github.com/users/jniles/followers","following_url":"https://api.github.com/users/jniles/following{/other_user}","gists_url":"https://api.github.com/users/jniles/gists{/gist_id}","starred_url":"https://api.github.com/users/jniles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jniles/subscriptions","organizations_url":"https://api.github.com/users/jniles/orgs","repos_url":"https://api.github.com/users/jniles/repos","events_url":"https://api.github.com/users/jniles/events{/privacy}","received_events_url":"https://api.github.com/users/jniles/received_events","type":"User","site_admin":false},"created_at":"2015-12-13T20:55:52Z","updated_at":"2015-12-13T20:55:52Z","body":"The merits of this have been proved on many pages, even with complex disabled options and hierarchies.  The most complex case can be seen [here](https://github.com/IMA-WorldHealth/bhima/blob/development/client/src/partials/cash/cashboxes/modal.html#L24)."}}