{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular.io/issues/3317","repository_url":"https://api.github.com/repos/angular/angular.io","labels_url":"https://api.github.com/repos/angular/angular.io/issues/3317/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular.io/issues/3317/comments","events_url":"https://api.github.com/repos/angular/angular.io/issues/3317/events","html_url":"https://github.com/angular/angular.io/issues/3317","id":210891503,"number":3317,"title":"fix(ngUpgrade): example bootstraps in the wrong zone","user":{"login":"wardbell","id":129061,"avatar_url":"https://avatars2.githubusercontent.com/u/129061?v=3","gravatar_id":"","url":"https://api.github.com/users/wardbell","html_url":"https://github.com/wardbell","followers_url":"https://api.github.com/users/wardbell/followers","following_url":"https://api.github.com/users/wardbell/following{/other_user}","gists_url":"https://api.github.com/users/wardbell/gists{/gist_id}","starred_url":"https://api.github.com/users/wardbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wardbell/subscriptions","organizations_url":"https://api.github.com/users/wardbell/orgs","repos_url":"https://api.github.com/users/wardbell/repos","events_url":"https://api.github.com/users/wardbell/events{/privacy}","received_events_url":"https://api.github.com/users/wardbell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-02-28T20:13:30Z","updated_at":"2017-03-01T20:52:25Z","closed_at":null,"body":"@mhevery sez:\r\n\r\nI just noticed that there is a wrong `ngUpgrade` example in our docs. Could we get it fixed?\r\n\r\nThe issue is here:\r\n```\r\nimport { platformBrowserDynamic } from '@angular/platform-browser-dynamic';\r\nplatformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => {\r\n  const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule;\r\n  upgrade.bootstrap(document.body, ['heroApp'], {strictDi: true});\r\n});\r\n```\r\nBecause `.then` gets invoked in the same zone as the zone at the time of invocation it means that it will run in the `<root>` zone. The implication is that when `upgrade.bootstrap` executes it too will run in `<root>` zone. This creates subtle problems. \r\n\r\nIn my opinion the fix is to move the `upgrade.bootstrap` call into the constructor of the the top level module. The constructor is invoked in the correct `NgZone`.\r\n\r\n```\r\nimport { HeroDetailComponent } from './hero-detail.component';\r\n@NgModule({\r\n  imports: [\r\n    BrowserModule,\r\n    UpgradeModule\r\n  ]\r\n})\r\nexport class AppModule {\r\n  constructor(upgrade: UpgradeModule) {\r\n    upgrade.bootstrap(document.body, ['heroApp'], {strictDi: true});\r\n  }\r\n\r\n  ngDoBootstrap() {}\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/angular/angular.io/issues/comments/283466254","html_url":"https://github.com/angular/angular.io/issues/3317#issuecomment-283466254","issue_url":"https://api.github.com/repos/angular/angular.io/issues/3317","id":283466254,"user":{"login":"petebacondarwin","id":15655,"avatar_url":"https://avatars3.githubusercontent.com/u/15655?v=3","gravatar_id":"","url":"https://api.github.com/users/petebacondarwin","html_url":"https://github.com/petebacondarwin","followers_url":"https://api.github.com/users/petebacondarwin/followers","following_url":"https://api.github.com/users/petebacondarwin/following{/other_user}","gists_url":"https://api.github.com/users/petebacondarwin/gists{/gist_id}","starred_url":"https://api.github.com/users/petebacondarwin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petebacondarwin/subscriptions","organizations_url":"https://api.github.com/users/petebacondarwin/orgs","repos_url":"https://api.github.com/users/petebacondarwin/repos","events_url":"https://api.github.com/users/petebacondarwin/events{/privacy}","received_events_url":"https://api.github.com/users/petebacondarwin/received_events","type":"User","site_admin":false},"created_at":"2017-03-01T20:52:25Z","updated_at":"2017-03-01T20:52:25Z","body":"OK we have spoken and I understand the problem. The first port of call is to update the docs and explain why it was wrong. We are going to change the library to throw an error if they do it the `then` way.\r\nI will send in a PR tomorrow for the docs."}}
{"actor":{"display_login":"petebacondarwin"}}