{"action":"closed","issue":{"url":"https://api.github.com/repos/angular/angular/issues/13245","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/13245/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/13245/comments","events_url":"https://api.github.com/repos/angular/angular/issues/13245/events","html_url":"https://github.com/angular/angular/issues/13245","id":193580082,"number":13245,"title":"[2.2.1] ngOnChanges() doesn't get called when an @Input() property is changed","user":{"login":"skateXY","id":24392577,"avatar_url":"https://avatars.githubusercontent.com/u/24392577?v=3","gravatar_id":"","url":"https://api.github.com/users/skateXY","html_url":"https://github.com/skateXY","followers_url":"https://api.github.com/users/skateXY/followers","following_url":"https://api.github.com/users/skateXY/following{/other_user}","gists_url":"https://api.github.com/users/skateXY/gists{/gist_id}","starred_url":"https://api.github.com/users/skateXY/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skateXY/subscriptions","organizations_url":"https://api.github.com/users/skateXY/orgs","repos_url":"https://api.github.com/users/skateXY/repos","events_url":"https://api.github.com/users/skateXY/events{/privacy}","received_events_url":"https://api.github.com/users/skateXY/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-05T18:54:22Z","updated_at":"2016-12-05T19:54:32Z","closed_at":"2016-12-05T19:54:32Z","body":"<!--\r\nIF YOU DON'T FILL OUT THE FOLLOWING INFORMATION WE MIGHT CLOSE YOUR ISSUE WITHOUT INVESTIGATING\r\n-->\r\n\r\n**I'm submitting a ...**  (check one with \"x\")\r\n```\r\n[x] bug report => search github for a similar issue or PR before submitting\r\n[ ] feature request\r\n[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\r\n```\r\n\r\n**Current behavior**\r\n<!-- Describe how the bug manifests. -->\r\n\r\nI'm trying to change a child's @Input() property using an @ViewChild instance in the parent,\r\nand the method ngOnChanges() doesn't get called.\r\n\r\nChanging \"currentVal\" in the parent will trigger an ngOnChanges() on the child.\r\n\r\nAlso, if I update \"this.siderbarInstance.testVal\" from the parent, the change will appear in DOM,\r\nbut  ngOnChanges() won't get called.\r\n\r\n**Expected behavior**\r\n<!-- Describe what the behavior would be without the bug. -->\r\n\r\nThe method ngOnChanges() should be called every time when a property is changed, and I should be able to get the changes.\r\nIf this shouldn't be possible then angular should throw an error, because silent fail isn't an accepted behaviour.\r\n\r\n**Minimal reproduction of the problem with instructions**\r\n<!--\r\nIf the current behavior is a bug or you can illustrate your feature request better with an example, \r\nplease provide the *STEPS TO REPRODUCE* and if possible a *MINIMAL DEMO* of the problem via\r\nhttps://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).\r\n-->\r\n\r\n@Component({\r\n  selector: 'my-app',\r\n  template: `<div class=\"wrapper\"> <my-sidebar [testVal]=\"currentVal\"></my-sidebar></div>`,\r\n  providers: [AppService]\r\n})\r\n\r\nexport class AppComponent  { \r\n\r\n  @ViewChild(SidebarComponent) siderbarInstance: SidebarComponent;\r\n  public currentVal : string;\r\n\r\n  public onInnerClick(): void {\r\n        this.siderbarInstance.testVal = \"I clicked\";\r\n  }\r\n\r\n}\r\n\r\n@Component({\r\n  selector: 'my-sidebar',\r\n  template: `<div class=\"sidebar\"> Current child's value: {{testVal}} </div>`,\r\n})\r\n\r\nexport class SidebarComponent implements OnInit, OnChanges, DoCheck {\r\n \r\n    @Input() testVal : string;\r\n\r\n    public ngOnChanges(): void{\r\n        console.log(this.testVal);\r\n    }\r\n}\r\n\r\n\r\n\r\n\r\n**What is the motivation / use case for changing the behavior?**\r\n<!-- Describe the motivation or the concrete use case -->\r\n\r\nI'm just learning angular2 and ngOnChanges() doesn't seem reliable if it's not called every time\r\nwhen a change occurs. \r\n\r\n**Please tell us about your environment:**\r\n<!-- Operating system, IDE, package manager, HTTP server, ... -->\r\n\r\nWindows 10, Visual Studio Code, npm\r\n\r\n* **Angular version:** 2.0.X\r\n<!-- Check whether this is still an issue in the most recent Angular version -->\r\n\r\n[2.2.1]\r\n\r\n* **Browser:** [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]\r\n<!-- All browsers where this could be reproduced -->\r\n\r\nChrome, IE11.\r\n \r\n* **Language:** [all | TypeScript X.X | ES6/7 | ES5]\r\n\r\nTypescript 2.0.1\r\n\r\n* **Node (for AoT issues):** `node --version` =   \r\n"}}
{"actor":{"display_login":"alxhub"}}