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

I must use $apply() to see changes...? #203

Closed
edin-m opened this issue Dec 24, 2016 · 1 comment
Closed

I must use $apply() to see changes...? #203

edin-m opened this issue Dec 24, 2016 · 1 comment

Comments

@edin-m
Copy link

edin-m commented Dec 24, 2016

I have simple component/controller/html for "file manager" so:

html:

  <div>
    {{ ($ctrl.wickedSick || {}) | json }}
  </div>

component:

export default {
  restrict: 'E',
  bindings: {},
  template,
  controller
};

and controller:

class FileManagerController {
  constructor($scope) {
    this.wickedSick = 'wicked sick !!! 123';
    setTimeout(() => {
      this.wickedSick = 'new value';
      $scope.$apply();
    }, 5000);
  }
}

If I don't have $scope.$apply() I don't se resulting changes. And I would like not to use $apply() manually... Am I doing something wrong?

@edin-m edin-m closed this as completed Dec 24, 2016
@fesor
Copy link
Collaborator

fesor commented Dec 25, 2016

you should wrap all async functions to make them start digest cycle. In case of setTimeout angular provides you $timeout service which handles digest for you.

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