{"action":"created","issue":{"url":"https://api.github.com/repos/formly-js/angular-formly/issues/246","labels_url":"https://api.github.com/repos/formly-js/angular-formly/issues/246/labels{/name}","comments_url":"https://api.github.com/repos/formly-js/angular-formly/issues/246/comments","events_url":"https://api.github.com/repos/formly-js/angular-formly/issues/246/events","html_url":"https://github.com/formly-js/angular-formly/issues/246","id":68902221,"number":246,"title":"Dynamic Fields (ie from API)","user":{"login":"n0rb","id":1090783,"avatar_url":"https://avatars.githubusercontent.com/u/1090783?v=3","gravatar_id":"","url":"https://api.github.com/users/n0rb","html_url":"https://github.com/n0rb","followers_url":"https://api.github.com/users/n0rb/followers","following_url":"https://api.github.com/users/n0rb/following{/other_user}","gists_url":"https://api.github.com/users/n0rb/gists{/gist_id}","starred_url":"https://api.github.com/users/n0rb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/n0rb/subscriptions","organizations_url":"https://api.github.com/users/n0rb/orgs","repos_url":"https://api.github.com/users/n0rb/repos","events_url":"https://api.github.com/users/n0rb/events{/privacy}","received_events_url":"https://api.github.com/users/n0rb/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/formly-js/angular-formly/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/formly-js/angular-formly/labels/PRs%20please!","name":"PRs please!","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-04-16T11:18:05Z","updated_at":"2015-04-30T14:46:44Z","closed_at":null,"body":"Hi Kent,\r\n\r\nfirst I want to thank you and all the contributors for your awesome module!\r\nI've been using it alot in my projects but I have one problem I cannot get around:\r\n\r\nI mostly use a server API to provide the form metadata (form field definitions).\r\nThere are several requests to the API, ie onchangesubmit of a select value etc.\r\nThe API may or may not add/remove fields from the metadata on requests.\r\n\r\nHowever if I don't clear the fields before setting the new fields, either the model gets screwed up (type mismatch ie between string and number) or formly throws an exception at some point.\r\n\r\nThe problem with clearing the fields and then setting the new fields (this actually only works using $timeout for setting the new fields), the page may flicker (just for a moment but you do notice it), lose focus etc because for a moment the document does not have the controls anymore and is blank.\r\n\r\nAnyway I cloned an example from the formly examples and added a simple test to provide an example of the problem: http://jsbin.com/quyipiqenu/3/edit\r\nit sets new formly fields after 5 seconds via $timeout.\r\nthe new fields contain one more input field, but as you can see formly \"crashes\" and renders two selects.\r\n\r\nif you activate the prior $timeout, which clears the existing formfields at 4 seconds, the form will render correctly and produce no errors.\r\n\r\nSo, is there a way to dynamically update the existing fields of a formly form after it has been rendered ?\r\nI hope you can shed some light on this issue which has troubled me since formly 1 ;)"},"comment":{"url":"https://api.github.com/repos/formly-js/angular-formly/issues/comments/97825686","html_url":"https://github.com/formly-js/angular-formly/issues/246#issuecomment-97825686","issue_url":"https://api.github.com/repos/formly-js/angular-formly/issues/246","id":97825686,"user":{"login":"kentcdodds","id":1500684,"avatar_url":"https://avatars.githubusercontent.com/u/1500684?v=3","gravatar_id":"","url":"https://api.github.com/users/kentcdodds","html_url":"https://github.com/kentcdodds","followers_url":"https://api.github.com/users/kentcdodds/followers","following_url":"https://api.github.com/users/kentcdodds/following{/other_user}","gists_url":"https://api.github.com/users/kentcdodds/gists{/gist_id}","starred_url":"https://api.github.com/users/kentcdodds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentcdodds/subscriptions","organizations_url":"https://api.github.com/users/kentcdodds/orgs","repos_url":"https://api.github.com/users/kentcdodds/repos","events_url":"https://api.github.com/users/kentcdodds/events{/privacy}","received_events_url":"https://api.github.com/users/kentcdodds/received_events","type":"User","site_admin":false},"created_at":"2015-04-30T14:46:44Z","updated_at":"2015-04-30T14:46:44Z","body":"If you do break it, feel free to [add a failing test](https://github.com/formly-js/angular-formly/blob/master/src/directives/formly-form.test.js#L212) and I'll take it as a challenge :-)"}}