Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to bind app.service property to the view? #474

Closed
MurhafSousli opened this issue Mar 27, 2016 · 2 comments
Closed

how to bind app.service property to the view? #474

MurhafSousli opened this issue Mar 27, 2016 · 2 comments
Assignees

Comments

@MurhafSousli
Copy link

Hi, I'm trying to use app.service to get/set global loading state.
in app.html I print the loadState, {{loadState}} which supposed to be bound to appState.get().loadState

<div class="app-inner">
  loading : {{loadState}}
  <header></header>
  <main layout="column" layout-fill>
    <router-outlet></router-outlet>
  </main>
</div>

app.ts

export class App{

  constructor(public appState: AppState) {
    this.appState.set('loadState', false);  //initial value.
  }
  get loadState() {
    return this.appState.get().loadState;
  }
}

however I'm getting this error: EXCEPTION: Expression 'loading: {{loadState}} in App@0:23' has changed after it was checked. Previous value: 'false'. Current value: 'true' in [loading: {{loadState}} in App@0:23]

the error is clear, but I can't figure out how to fix it? am I using app.service the wrong way?

@PatrickJS
Copy link
Owner

I'm going to change the angular2-hmr api and remove the getter so it's not confusing

@PatrickJS PatrickJS self-assigned this Mar 28, 2016
@PatrickJS
Copy link
Owner

sorry this may sound super rule but I'm closing long standing issues and refactoring the codebase. If you run into this problem again feel free to open another issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants