Data is clicked back

0

I have an application in Angular 2 where I have some data insertion screens ( inputs ). When the user types the infos and clicks to go forward, clicking the back button gives the information. I tried to do something in LocalStorage to persist this data:

PersisteDados() {
    this.LocalStorageService.get('addons');
    this.LocalStorageService.get('contador');
  }

And I called on onInit() to load when view started, but did not roll. What would be the best way to do this persistence?

    
asked by anonymous 27.09.2017 / 16:57

1 answer

0

Use resolve is basically a condition to be met before the view is loaded, in angular , documentation example

class Backend {
  fetchTeam(id: string) {
    return 'someTeam';
  }
}

@Injectable()
class TeamResolver implements Resolve<Team> {
  constructor(private backend: Backend) {}

  resolve(
    route: ActivatedRouteSnapshot,
    state: RouterStateSnapshot): Observable<any>|Promise<any>|any {
    return this.backend.fetchTeam(route.params.id);
  }
}

@NgModule({
  imports: [
    RouterModule.forRoot([
      {
        path: 'team/:id',
        component: TeamCmp,
        resolve: {
          team: TeamResolver
        }
      }
    ])
  ],
  providers: [TeamResolver]
})
class AppModule {}

in angularjs Resolve angular 1

    
27.09.2017 / 17:12