Title: Select-Option: SelectedValue not working when changing DataSource · Issue #13884 · angular/angular · GitHub
Open Graph Title: Select-Option: SelectedValue not working when changing DataSource · Issue #13884 · angular/angular
X Title: Select-Option: SelectedValue not working when changing DataSource · Issue #13884 · angular/angular
Description: Hi all, i'm having a problem with the data binding of SelectedValue of select-option(ComboBox) when I change the DataSource during runtime. I have a select-option and bind it with a list. The content of the list will be changed during ru...
Open Graph Description: Hi all, i'm having a problem with the data binding of SelectedValue of select-option(ComboBox) when I change the DataSource during runtime. I have a select-option and bind it with a list. The conte...
X Description: Hi all, i'm having a problem with the data binding of SelectedValue of select-option(ComboBox) when I change the DataSource during runtime. I have a select-option and bind it with a list. The c...
Opengraph URL: https://github.com/angular/angular/issues/13884
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Select-Option: SelectedValue not working when changing DataSource","articleBody":"Hi all,\r\ni'm having a problem with the data binding of SelectedValue of select-option(ComboBox) when I change the DataSource during runtime.\r\n\r\nI have a select-option and bind it with a list. The content of the list will be changed during run-time (cleared and inserted with new item). At the beginning I fill the list with these data\r\n\r\n mockData1: ListItem[] = [\r\n { V: \"CH\", D: \"Schweiz\" },\r\n { V: \"DE\", D: \"Deutschland\" },\r\n { V: \"VN\", D: \"Vietnam\" }\r\n ];\r\n\r\nIn the UI, I select DE-Deutschland which means that my current selected-value is DE.\r\nThen I clear the list and fill it with other data\r\n\r\n mockData2: ListItem[] = [\r\n { V: \"CH\", D: \"Schweiz\" },\r\n { V: \"DE\", D: \"Deutschland\" },\r\n { V: \"VN\", D: \"Vietnam\" },\r\n { V: \"US\", D: \"USA\" }\r\n ];\r\n\r\nProblem: My current selected-value is still DE, but in the UI nothing is selected.\r\nQuestion: What should I do so that the databinding still works after I refresh the datasource? Thank you.\r\n\r\nI create a sample here https://github.com/rongchaua/angularselect\r\nOr in short version\r\n\r\n```\r\nexport class AppComponent implements OnInit {\r\n\r\n items: ListItem[] = [];\r\n mockData1: ListItem[] = [\r\n { V: \"CH\", D: \"Schweiz\" },\r\n { V: \"DE\", D: \"Deutschland\" },\r\n { V: \"VN\", D: \"Vietnam\" }\r\n ];\r\n mockData2: ListItem[] = [\r\n { V: \"CH\", D: \"Schweiz\" },\r\n { V: \"DE\", D: \"Deutschland\" },\r\n { V: \"VN\", D: \"Vietnam\" },\r\n { V: \"US\", D: \"USA\" }\r\n ];\r\n model: string;\r\n\r\n constructor(\r\n private http: Http\r\n ) {\r\n\r\n }\r\n\r\n load1() {\r\n console.log(\"list 1 loaded\");\r\n this.items.length = 0;\r\n for (let item of this.mockData1) {\r\n this.items.push(item);\r\n }\r\n }\r\n\r\n load2() {\r\n console.log(\"list 2 loaded\");\r\n this.items.length = 0;\r\n for (let item of this.mockData2) {\r\n this.items.push(item);\r\n }\r\n }\r\n\r\n ngOnInit(): void {\r\n this.load1();\r\n }\r\n}\r\n```\r\n\r\n```\r\n\u003cdiv class=\"row top-buffer\">\r\n \u003clabel class=\"col-md-3\" for=\"\">Lala\u003c/label>\r\n \u003cdiv class=\"col-md-9\">\r\n \u003cselect class=\"form-control\" name=\"\" [(ngModel)]=\"model\">\r\n \u003coption *ngFor=\"let item of items\" [ngValue]=\"item.V\">{{item.D}}\u003c/option>\r\n \u003c/select>\r\n \u003c/div>\r\n\u003c/div>\r\n\u003cdiv>\r\n {{model}}\r\n\u003c/div>\r\n\u003cdiv>\r\n \u003cbutton (click)=\"load1()\">Load list 1\u003c/button>\r\n \u003cbutton (click)=\"load2()\">Load list 2\u003c/button>\r\n\u003c/div>\r\n```\r\n\r\n\r\n\r\n","author":{"url":"https://github.com/rongchaua","@type":"Person","name":"rongchaua"},"datePublished":"2017-01-12T07:47:06Z","url":"https://github.com/angular/angular/issues/13884"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a19829b8-fb57-eb05-50c1-60c2892b3559 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D58:3D97C8:1349CF5:19AEB99:6B0126EF |
| html-safe-nonce | 968b4bef7b9a7504d0c43884026875a10a4199b8cfeed1fed0620c95d0b58992 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDU4OjNEOTdDODoxMzQ5Q0Y1OjE5QUVCOTk6NkIwMTI2RUYiLCJ2aXNpdG9yX2lkIjoiNTU2NTE4NzA0NzkwNTM3MTg4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 85a45e25ee19f00392b92eaa168a70f2d9f0ba07376c7774cf2288bebed88fa6 |
| hovercard-subject-tag | issue:200299461 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/13884/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e391a31efa1784598083a6c8f520385d81c7c6812ae9d382b63e07ef84aee496/angular/angular/issues/13884 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e391a31efa1784598083a6c8f520385d81c7c6812ae9d382b63e07ef84aee496/angular/angular/issues/13884 |
| og:image:alt | Hi all, i'm having a problem with the data binding of SelectedValue of select-option(ComboBox) when I change the DataSource during runtime. I have a select-option and bind it with a list. The conte... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rongchaua |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width