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

cgBusy no longer accepts string ids to represent promises/trackers #59

Closed
searope opened this issue Apr 2, 2015 · 2 comments
Closed

Comments

@searope
Copy link

searope commented Apr 2, 2015

Hello,
I have a table loaded dynamically and its rows can be expanded with AJAX calls on user clicks. I'd like to show spinner while these secondary data is loaded. But I cannot use one promise variable for that since it shows the spinner in all rows. So I've tried to create the promise variables on the fly when the parent table is loaded. But when I try to access the dynamic variables I'm getting the error in the subject. How could I work around this?
html:

<div ng-repeat="link in table">
  <div ng-click="loadRow(link)">
    <div cg-busy="'p'+link.fromId+'-'+link.toId"></div>
  </div>
</div>

js:

$scope.loadRow(link){
  $scope['p'+link.fromId+'-'+link.toId] = $http.get('...');
}
@cgross
Copy link
Owner

cgross commented Apr 2, 2015

The expression you're passing to cg-busy is evaluating to a string, not a promise. Thats why you're getting that error. Do this:

$scope.loadRow(link){
  if (!$scope.promises) {
    $scope.promises = {};
  }
  $scope.promises['p'+link.fromId+'-'+link.toId] = $http.get('...');
}
<div ng-repeat="link in table">
  <div ng-click="loadRow(link)">
    <div cg-busy="promises['p'+link.fromId+'-'+link.toId]"></div>
  </div>
</div>

@searope
Copy link
Author

searope commented Apr 2, 2015

thank you!

@searope searope closed this as completed Apr 2, 2015
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