{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/8315","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/8315/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/8315/comments","events_url":"https://api.github.com/repos/angular/angular/issues/8315/events","html_url":"https://github.com/angular/angular/issues/8315","id":151716577,"number":8315,"title":"[beta.16 regression] ngFor and ChangeDetectionStrategy.OnPush not updating with .markForCheck()","user":{"login":"stringham","id":1206952,"avatar_url":"https://avatars.githubusercontent.com/u/1206952?v=3","gravatar_id":"","url":"https://api.github.com/users/stringham","html_url":"https://github.com/stringham","followers_url":"https://api.github.com/users/stringham/followers","following_url":"https://api.github.com/users/stringham/following{/other_user}","gists_url":"https://api.github.com/users/stringham/gists{/gist_id}","starred_url":"https://api.github.com/users/stringham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stringham/subscriptions","organizations_url":"https://api.github.com/users/stringham/orgs","repos_url":"https://api.github.com/users/stringham/repos","events_url":"https://api.github.com/users/stringham/events{/privacy}","received_events_url":"https://api.github.com/users/stringham/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2016-04-28T18:52:43Z","updated_at":"2016-05-08T15:57:08Z","closed_at":null,"body":"This may be related to #8242 but that issue is specifically about event handlers not causing the change detector to run, and I saw that they got it working by adding a call to `.markForCheck()` on the ChangeDetectorRef.\r\n\r\nI'm seeing that change detection isn't working even with a `.markForCheck()` call.\r\n\r\nI have a component that keeps a count that increments on an interval, note it marks the change detector after changing the count.\r\n\r\n```javascript\r\nvar Component1 = ng.core\r\n    .Component({\r\n        selector:\"cmp1\",\r\n        template:\"<div>Count: {{count}}</div>\",\r\n    })\r\n    .Class({\r\n        constructor:[\r\n            ng.core.ChangeDetectorRef,\r\n            function(cdr){\r\n              this.count = 0;\r\n              setInterval(function(){\r\n                this.count++;\r\n                cdr.markForCheck();\r\n              }.bind(this), 500);\r\n\r\n            }\r\n        ]\r\n    });\r\n```\r\n\r\nI have another component that uses that component in an *ngFor with changeDetectionStrategy.OnPush\r\n\r\n```javascript\r\nvar Component2 = ng.core\r\n    .Component({\r\n        selector:\"cmp2\",\r\n        template:'<div>Component 2 (ngfor):</div><cmp1 *ngFor=\"#a of [1,2]\"></cmp1>',\r\n        directives:[Component1],\r\n        changeDetection: ng.core.ChangeDetectionStrategy.OnPush,\r\n    })\r\n    .Class({\r\n        constructor:[\r\n            function(){}\r\n        ]\r\n    });\r\n```\r\n\r\nand another component that uses the first component twice, not in an *ngFor\r\n\r\n```\r\nvar Component3 = ng.core\r\n    .Component({\r\n        selector:\"cmp3\",\r\n        template:'<div>Component 3 (no ngfor):</div><cmp1></cmp1><cmp1></cmp1>',\r\n        directives:[Component1],\r\n        changeDetection: ng.core.ChangeDetectionStrategy.OnPush,\r\n    })\r\n    .Class({\r\n        constructor:[\r\n            function(){}\r\n        ]\r\n    });\r\n```\r\n\r\nand the root app uses all three components.\r\n\r\n```javascript\r\nvar AppComponent = ng.core\r\n    .Component({\r\n        selector:'test-app',\r\n        template:`\r\n            <cmp1></cmp1>\r\n            <cmp2></cmp2>\r\n            <cmp3></cmp3>\r\n        `,\r\n        directives:[\r\n            Component1,\r\n            Component2,\r\n            Component3,\r\n        ]\r\n    })\r\n    .Class({\r\n        constructor:[\r\n            function() {\r\n                window.app = this;\r\n            }\r\n        ]\r\n    });\r\n```\r\n\r\nIn beta.16 component 1 and 3 update, but component 2 stays at 0.\r\nIn beta.15 they all update as expected.\r\n\r\nHere's a plnkr of it not working in beta.16: http://plnkr.co/edit/waoh6evhRvOvX1yMuOKG?p=preview\r\nHere's the same thing in beta.15: http://plnkr.co/edit/a5POuqddYbG5C9oVuzA8?p=preview"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/217729274","html_url":"https://github.com/angular/angular/issues/8315#issuecomment-217729274","issue_url":"https://api.github.com/repos/angular/angular/issues/8315","id":217729274,"user":{"login":"born2net","id":5090936,"avatar_url":"https://avatars.githubusercontent.com/u/5090936?v=3","gravatar_id":"","url":"https://api.github.com/users/born2net","html_url":"https://github.com/born2net","followers_url":"https://api.github.com/users/born2net/followers","following_url":"https://api.github.com/users/born2net/following{/other_user}","gists_url":"https://api.github.com/users/born2net/gists{/gist_id}","starred_url":"https://api.github.com/users/born2net/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/born2net/subscriptions","organizations_url":"https://api.github.com/users/born2net/orgs","repos_url":"https://api.github.com/users/born2net/repos","events_url":"https://api.github.com/users/born2net/events{/privacy}","received_events_url":"https://api.github.com/users/born2net/received_events","type":"User","site_admin":false},"created_at":"2016-05-08T15:57:08Z","updated_at":"2016-05-08T15:57:08Z","body":"tx for update"}}