{"action":"created","issue":{"url":"https://api.github.com/repos/marmelab/ng-admin/issues/778","labels_url":"https://api.github.com/repos/marmelab/ng-admin/issues/778/labels{/name}","comments_url":"https://api.github.com/repos/marmelab/ng-admin/issues/778/comments","events_url":"https://api.github.com/repos/marmelab/ng-admin/issues/778/events","html_url":"https://github.com/marmelab/ng-admin/issues/778","id":116583162,"number":778,"title":"Updated to 0.9, now getting `t.choices` is not a function","user":{"login":"OverZealous","id":965719,"avatar_url":"https://avatars.githubusercontent.com/u/965719?v=3","gravatar_id":"","url":"https://api.github.com/users/OverZealous","html_url":"https://github.com/OverZealous","followers_url":"https://api.github.com/users/OverZealous/followers","following_url":"https://api.github.com/users/OverZealous/following{/other_user}","gists_url":"https://api.github.com/users/OverZealous/gists{/gist_id}","starred_url":"https://api.github.com/users/OverZealous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OverZealous/subscriptions","organizations_url":"https://api.github.com/users/OverZealous/orgs","repos_url":"https://api.github.com/users/OverZealous/repos","events_url":"https://api.github.com/users/OverZealous/events{/privacy}","received_events_url":"https://api.github.com/users/OverZealous/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-11-12T16:17:15Z","updated_at":"2015-11-18T15:26:38Z","closed_at":null,"body":"Every time I switch to an edit page, I'm now getting this error:\r\n\r\n```\r\nError: t.choices is not a function\r\nr/<.compile/<.pre@http://localhost:3001/adm/js/vendor/ng-admin/build/ng-admin.min.js:15:2543\r\n\r\n«snipped Angular call stack »\r\n\r\n <ma-choice-field class=\"ng-isolate-scope\" field=\"::field\" entry=\"entry\" value=\"value\">\r\n```\r\n\r\nI've narrowed it down to [line 36 of maChoiceField.js](https://github.com/marmelab/ng-admin/blob/master/src/javascripts/ng-admin/Crud/field/maChoiceField.js#L36).  I don't know exactly what's wrong.  I think it's a mistake, because it calls the function _then_ uses the result.\r\n\r\nLooks like the change was made in commit 0f0693647f252783d7cb4b0ecd6f1ef00c333167.\r\n\r\nIf it matters, these fields are using a custom function for the choices.  It's a bit of a hack to allow me to asynchronously load some meta data from the server, but it shouldn't affect anything.  The way it works is like this:\r\n\r\n```js\r\nlet someChoices = [];\r\napp.config(function(...) {\r\n    field.choices(() => someChoices);\r\n});\r\n\r\n...\r\n\r\napp.run(function ($http) {\r\n    // load remote values\r\n    someChoices = remoteValues;\r\n});\r\n```\r\n\r\nI'd make a minimal test case, but I'm honestly trying to figure out how to do that, since you need a RESTful backend."},"comment":{"url":"https://api.github.com/repos/marmelab/ng-admin/issues/comments/157748253","html_url":"https://github.com/marmelab/ng-admin/issues/778#issuecomment-157748253","issue_url":"https://api.github.com/repos/marmelab/ng-admin/issues/778","id":157748253,"user":{"login":"OverZealous","id":965719,"avatar_url":"https://avatars.githubusercontent.com/u/965719?v=3","gravatar_id":"","url":"https://api.github.com/users/OverZealous","html_url":"https://github.com/OverZealous","followers_url":"https://api.github.com/users/OverZealous/followers","following_url":"https://api.github.com/users/OverZealous/following{/other_user}","gists_url":"https://api.github.com/users/OverZealous/gists{/gist_id}","starred_url":"https://api.github.com/users/OverZealous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OverZealous/subscriptions","organizations_url":"https://api.github.com/users/OverZealous/orgs","repos_url":"https://api.github.com/users/OverZealous/repos","events_url":"https://api.github.com/users/OverZealous/events{/privacy}","received_events_url":"https://api.github.com/users/OverZealous/received_events","type":"User","site_admin":false},"created_at":"2015-11-18T15:26:38Z","updated_at":"2015-11-18T15:26:38Z","body":"OK, this fix worked for me on Angular 1.4.7:\r\n\r\n```js\r\nvar choices = (angular.isFunction(scope.choices) && scope.choices()) ? scope.choices : (field.choices ? field.choices() : [])\r\n```"}}