{"action":"closed","issue":{"url":"https://api.github.com/repos/driftyco/ionic2/issues/812","labels_url":"https://api.github.com/repos/driftyco/ionic2/issues/812/labels{/name}","comments_url":"https://api.github.com/repos/driftyco/ionic2/issues/812/comments","events_url":"https://api.github.com/repos/driftyco/ionic2/issues/812/events","html_url":"https://github.com/driftyco/ionic2/issues/812","id":123867093,"number":812,"title":"Can't uses \"this\" in onPageLoaded() or ngOnInit()","user":{"login":"kitkimwong","id":11818108,"avatar_url":"https://avatars.githubusercontent.com/u/11818108?v=3","gravatar_id":"","url":"https://api.github.com/users/kitkimwong","html_url":"https://github.com/kitkimwong","followers_url":"https://api.github.com/users/kitkimwong/followers","following_url":"https://api.github.com/users/kitkimwong/following{/other_user}","gists_url":"https://api.github.com/users/kitkimwong/gists{/gist_id}","starred_url":"https://api.github.com/users/kitkimwong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kitkimwong/subscriptions","organizations_url":"https://api.github.com/users/kitkimwong/orgs","repos_url":"https://api.github.com/users/kitkimwong/repos","events_url":"https://api.github.com/users/kitkimwong/events{/privacy}","received_events_url":"https://api.github.com/users/kitkimwong/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/driftyco/ionic2/labels/needs%20reply","name":"needs reply","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-25T09:16:30Z","updated_at":"2015-12-26T08:26:03Z","closed_at":"2015-12-26T08:26:03Z","body":"```\r\n@Page({\r\n  templateUrl: 'build/pages/HomePage/HomePage.html',\r\n  lifecycle: [onInit]\r\n})\r\nexport class HomePage {\r\n\r\n  constructor(app: IonicApp  , actionSheet: ActionSheet , nav : NavController ) {\r\n  \tconsole.log(\"creattttttt\");\r\n\t\tthis.nav = nav;\r\n//\t\tthis.dataService = dataService;\r\n\t\tthis.actionSheet = actionSheet;\r\n\t\tthis.selectedItem = {\r\n\t\t\ttitle : \"\",\r\n\t\t\ticon : \"\"\r\n\t\t}\r\n\t\tthis.aaa();\t\r\n  }\r\n\t\r\n  ngOnInit() {\r\n\tconsole.log(this); // undefine  \r\n     this.alertfunction();   //occur errors !\r\n  }\t\t\r\n  \r\n  onPageLoaded(){\r\n     console.log(this); // undefine\r\n     this.alertfunction();   //occur errors !\r\n  }\t\r\n\r\n  alertfunction(){\r\n     alert(\"alert\");\r\n   }\r\n  \r\n}\r\n```\r\nCan't use this in scope ngOnInit / onPageLoaded"}}