Title: Passing in an a function to the ngOptions array clause that generates elements on the fly results in infinite $digest loop · Issue #9464 · angular/angular.js · GitHub
Open Graph Title: Passing in an a function to the ngOptions array clause that generates elements on the fly results in infinite $digest loop · Issue #9464 · angular/angular.js
X Title: Passing in an a function to the ngOptions array clause that generates elements on the fly results in infinite $digest loop · Issue #9464 · angular/angular.js
Description: AngularJS 1.2.22 (in particular, commit c286094) has changed the behaviour of ngOptions from deep watching to shallow watching the elements of the array. If the array and its elements are generated by a function on the fly, shallow watch...
Open Graph Description: AngularJS 1.2.22 (in particular, commit c286094) has changed the behaviour of ngOptions from deep watching to shallow watching the elements of the array. If the array and its elements are generated...
X Description: AngularJS 1.2.22 (in particular, commit c286094) has changed the behaviour of ngOptions from deep watching to shallow watching the elements of the array. If the array and its elements are generated...
Opengraph URL: https://github.com/angular/angular.js/issues/9464
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Passing in an a function to the ngOptions array clause that generates elements on the fly results in infinite $digest loop","articleBody":"AngularJS 1.2.22 (in particular, commit c2860944c61a0b910f703fe8a9717188ed387893) has changed the behaviour of ngOptions from deep watching to shallow watching the elements of the array. If the array and its elements are generated by a function on the fly, shallow watching will fail as even if the elements are identical, they are separate instances. This results in infinite $digest loops:\n\n```\n Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!\n Watchers fired in the last 5 iterations: [[\"fn: $watchCollectionWatch; newVal: 37; oldVal: 32\"],[\"fn: $watchCollectionWatch; newVal: 42; oldVal: 37\"],[\"fn: $watchCollectionWatch; newVal: 47; oldVal: 42\"],[\"fn: $watchCollectionWatch; newVal: 52; oldVal: 47\"],[\"fn: $watchCollectionWatch; newVal: 57; oldVal: 52\"]]\n http://errors.angularjs.org/\"NG_VERSION_FULL\"/$rootScope/infdig?p0=10&p1=%5B%5B%22fn%3A%20%24watchCollectionWatch%3B%20newVal%3A%2037%3B%20oldVal%3A%2032%22%5D%2C%5B%22fn%3A%20%24watchCollectionWatch%3B%20newVal%3A%2042%3B%20oldVal%3A%2037%22%5D%2C%5B%22fn%3A%20%24watchCollectionWatch%3B%20newVal%3A%2047%3B%20oldVal%3A%2042%22%5D%2C%5B%22fn%3A%20%24watchCollectionWatch%3B%20newVal%3A%2052%3B%20oldVal%3A%2047%22%5D%2C%5B%22fn%3A%20%24watchCollectionWatch%3B%20newVal%3A%2057%3B%20oldVal%3A%2052%22%5D%5D\n at /Users/tamas/build/github.com/drjokepu/angular.js/src/minErr.js:73:12\n at Scope.$digest (/Users/tamas/build/github.com/drjokepu/angular.js/src/ng/rootScope.js:705:19)\n at Scope.$apply (/Users/tamas/build/github.com/drjokepu/angular.js/src/ng/rootScope.js:931:24)\n at null.\u003canonymous> (/Users/tamas/build/github.com/drjokepu/angular.js/test/ng/directive/selectSpec.js:1142:15)\n```\n\nA tracking expression clause is supported by ngOptions that explicitly defines the expression that is used for comparing array elements. However, currently this is only used for identifying the selected item and not used for watching the elements of the array itself. I am suggesting extending the usage of this expression to be also used for differentiating of the array items themselves when shallow watching.\n\n**Reproducible:** always\n**Browsers:** Tested on Chrome 37, Safari 7.1\n**Operating System:** OS X 10.9.5\n\nSteps to reproduce:\n- Create a new html file and add the following content:\n\n``` html\n\u003c!DOCTYPE html>\n\u003chtml>\n\u003chead>\n \u003ctitle>Infinite Digest\u003c/title>\n\u003c/head>\n\u003cbody>\n \u003cbody ng-app=\"demoApp\">\n \u003cscript type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js\">\u003c/script>\n \u003cscript type='text/javascript'>\n angular.module('demoApp', []).controller('DemoController', function($scope) {\n $scope.makeOptions = function() {\n var options = [];\n for (var i = 0; i \u003c 5; i++) {\n options.push({ label: 'Value = ' + i, value: i });\n }\n return options;\n };\n $scope.selected = { label: 'Value = 1', value: 1 };\n });\n \u003c/script>\n \u003cdiv ng-controller=\"DemoController\">\n \u003cdiv>\n \u003ch2>Infinite Digest\u003c/h2>\n \u003cselect ng-model=\"selected\"\n ng-options=\"opt as opt.label for opt in makeOptions() track by opt.value\">\n \u003c/select>\n The value selected is {{ selected.value }}.\n \u003c/div>\n \u003c/div>\n\u003c/body>\n\u003c/body>\n\u003c/html>\n```\n- Open this file in a browser. AngularJS will report infinite digest in the console.\n\nThis works fine on AngularJS 1.2.21 and earlier.\n\nI am not really an Angular developer (or a real JavaScript developer for that matter), but I am going to submit a pull request with a spec test as well as a proposed solution that will illustrate how I would go about tackling the issue,\n","author":{"url":"https://github.com/drjokepu","@type":"Person","name":"drjokepu"},"datePublished":"2014-10-07T15:35:31Z","url":"https://github.com/angular/angular.js/issues/9464"}
| 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:8435fcf2-d4d1-8e95-a4a1-a6cf6502e0c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C538:37B940:337A0A:495BFA:6AFDE747 |
| html-safe-nonce | 8ca3efa6abdf55a912cd0637be96ed72515fd18918fd7a33df17cdf78a7811ec |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTM4OjM3Qjk0MDozMzdBMEE6NDk1QkZBOjZBRkRFNzQ3IiwidmlzaXRvcl9pZCI6Ijc2NjU4NDk2OTgzMzgzMzQ1MzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 995c31816dba72713bdaee633e8359c7a1ca8e6860dfcba0e377b387a018c31c |
| hovercard-subject-tag | issue:45122299 |
| 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.js/9464/issue_layout |
| twitter:image | https://opengraph.githubassets.com/86df669790573fc052618f289bead37838c90ccb218432e3198e4333cc6fab26/angular/angular.js/issues/9464 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/86df669790573fc052618f289bead37838c90ccb218432e3198e4333cc6fab26/angular/angular.js/issues/9464 |
| og:image:alt | AngularJS 1.2.22 (in particular, commit c286094) has changed the behaviour of ngOptions from deep watching to shallow watching the elements of the array. If the array and its elements are generated... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | drjokepu |
| hostname | github.com |
| expected-hostname | github.com |
| None | 91ef1a291a064ac31ac459ab3f75261dbdd924c41ea5bd027e591c5b46cc9ce7 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular.js git https://github.com/angular/angular.js.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 460078 |
| octolytics-dimension-repository_nwo | angular/angular.js |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 460078 |
| octolytics-dimension-repository_network_root_nwo | angular/angular.js |
| 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 | d62bc98ce2346f4006e4a2810e9e22f37e7e6422 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width