No progress happening
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 & Continue</button>
The server is taking about 10sec to resolve the promise, the button doesnt fill and simply flips to the done animation.
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
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?
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.
I followed the instructions of md file, but I couldn't get any animation of the example page
@fpernia Could you please share your code with us?