{"action":"created","issue":{"url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/410","repository_url":"https://api.github.com/repos/NativeScript/nativescript-angular","labels_url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/410/labels{/name}","comments_url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/410/comments","events_url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/410/events","html_url":"https://github.com/NativeScript/nativescript-angular/issues/410","id":172685378,"number":410,"title":"Manipulation Done on Native Elements Removed on Back Navigation","user":{"login":"shripalsoni04","id":4411891,"avatar_url":"https://avatars.githubusercontent.com/u/4411891?v=3","gravatar_id":"","url":"https://api.github.com/users/shripalsoni04","html_url":"https://github.com/shripalsoni04","followers_url":"https://api.github.com/users/shripalsoni04/followers","following_url":"https://api.github.com/users/shripalsoni04/following{/other_user}","gists_url":"https://api.github.com/users/shripalsoni04/gists{/gist_id}","starred_url":"https://api.github.com/users/shripalsoni04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shripalsoni04/subscriptions","organizations_url":"https://api.github.com/users/shripalsoni04/orgs","repos_url":"https://api.github.com/users/shripalsoni04/repos","events_url":"https://api.github.com/users/shripalsoni04/events{/privacy}","received_events_url":"https://api.github.com/users/shripalsoni04/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-08-23T12:25:06Z","updated_at":"2016-08-24T11:05:22Z","closed_at":"2016-08-23T20:51:41Z","body":"It seems like any manipulations done on native android element is getting removed when we navigate back to the route having that component.\r\n\r\n## Preview of the Issue:\r\n![android-native-remove-on-route-change](https://cloud.githubusercontent.com/assets/4411891/17891460/8bf9526e-6959-11e6-8b15-ab45d305a893.gif)\r\n\r\n## Issue Description:\r\nHere, I have created a class directive with selector '.test-btn' and I have attached this class directive to the button on Page1. Now when we navigate to other page and come back to the page again, the background color that I set using native api is getting removed.\r\n\r\nI know we can set background color using nativescript only, but just to illustrate the issue easily, I am setting backgroundColor using native android api.\r\n\r\nI don't know the same issue is for iOS also or not as I have tested on android only till now.\r\n\r\n## Sample Project Code\r\nYou can find the sample project described above at https://github.com/shripalsoni04/ns-ng-route-change-issue.\r\n\r\nI am not sure but It seems like nativescript is creating the native button element again on back navigation and the directives attached to it are not executed again.\r\n\r\nIt will be great if we can find a solution for this.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/comments/242027762","html_url":"https://github.com/NativeScript/nativescript-angular/issues/410#issuecomment-242027762","issue_url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/410","id":242027762,"user":{"login":"vakrilov","id":4092076,"avatar_url":"https://avatars.githubusercontent.com/u/4092076?v=3","gravatar_id":"","url":"https://api.github.com/users/vakrilov","html_url":"https://github.com/vakrilov","followers_url":"https://api.github.com/users/vakrilov/followers","following_url":"https://api.github.com/users/vakrilov/following{/other_user}","gists_url":"https://api.github.com/users/vakrilov/gists{/gist_id}","starred_url":"https://api.github.com/users/vakrilov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vakrilov/subscriptions","organizations_url":"https://api.github.com/users/vakrilov/orgs","repos_url":"https://api.github.com/users/vakrilov/repos","events_url":"https://api.github.com/users/vakrilov/events{/privacy}","received_events_url":"https://api.github.com/users/vakrilov/received_events","type":"User","site_admin":false},"created_at":"2016-08-24T11:05:22Z","updated_at":"2016-08-24T11:05:22Z","body":"@shripalsoni04 - You got all things right. When navigating the components are cached, but the actual android views are recreated. So here are the 3 levels of abstraction here:\r\n\r\n1. Angular component - cached\r\n2. Nativescript View - cached\r\n3. Native platform view (IOS or Android specific) - not cached (unless `cachePagesOnNavigate=true`)\r\n\r\nAs the component instances are cached (lvl 1) the lifecycle hooks (`ngOnInit` for example) will not re-execute on navigation.\r\n\r\nIf you are touching the Native android view directly you can attach to the `loaded` event of the nativescript-view (lvl 2). It will fire every time the android view (lvl3) is created. I have done a [PR to your repo](https://github.com/shripalsoni04/ns-ng-route-change-issue/pull/1) with example.\r\n"}}
{"actor":{"display_login":"vakrilov"}}