Skip to content

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

Description

@MurhafSousli

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?

Activity

  1. PatrickJS commented on Mar 28, 2016

    @PatrickJS
    Owner

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

  2. self-assigned this
    on Mar 28, 2016
  3. PatrickJS commented on Sep 2, 2017

    @PatrickJS
    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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions