angular-progress-button-styles icon indicating copy to clipboard operation
angular-progress-button-styles copied to clipboard

No progress happening

Open doodirock opened this issue 10 years ago • 5 comments

Button doens't fill when I hook it into my service. Currently using:

$scope.change = function() {
  $scope.loader = NodeFactory.update({ id: $scope.newentry.nid }, $scope.data);
  $scope.loader.$promise.then(function () {
    //$state.go('start', {'id': $scope.newentry.nid});
  });
};

With my button set as:

    <button type="submit" progress-button="change()">Save &amp; Continue</button>

The server is taking about 10sec to resolve the promise, the button doesnt fill and simply flips to the done animation.

doodirock avatar May 31 '15 21:05 doodirock

Hey Joel,

You should return promise from the callback function. In your case this would probably be:

$scope.change = function() {
  $scope.loader = NodeFactory.update({ id: $scope.newentry.nid }, $scope.data);
  return $scope.loader.$promise.then(function () {
    //$state.go('start', {'id': $scope.newentry.nid});
  });
};

Note the return statement I added

Best, Vladimir

lugovsky avatar Jun 01 '15 07:06 lugovsky

How do you normally handle using it on a form since ng-submit handles disabling the page reload and usually contains the function associated with the promise you're return. Just git rid of ng-submit?

doodirock avatar Jun 02 '15 14:06 doodirock

Well, this plugin initially wasn't intended for the use with ngSubmit. Technically you can do it, but this would probably be a hack rather than proper usage. For example, you could create separate callback for progressButton, that will create promise object, that will be saved to some scope property. Later this promise can be resolved inside of ngSubmit's callback. But this all feels weird for me.

If you have no valuable reasons to have <button type="submit"> in you html and ng-submit on your form, just get rid of them and I guess you will be able to achieve what you want.

lugovsky avatar Jun 02 '15 20:06 lugovsky

I followed the instructions of md file, but I couldn't get any animation of the example page

fpernia avatar Aug 31 '15 02:08 fpernia

@fpernia Could you please share your code with us?

lugovsky avatar Aug 31 '15 08:08 lugovsky