In a directive, I have a call that takes some time. On that page, to prevent ppl from clicking on the UI elements, we disable the buttons until that call returns.
$scope.isLoading = true;
userService.getUser(true).then((user) => {
// some business logic
$scope.paidUser = true;
$scope.isLoading = false;
});
Then for a button it would be something like this:
$scope.buttonDisabled = $scope.isLoading || $scope.paidUser;
The states of the buttons in my directive also depend on other things like which elements are already selected in the UI. Do I write my unit test and just set $scope.isLoading = false
? Like in the unit test, I want the scenario where my service already returned and it's no longer loading any more.
Aucun commentaire:
Enregistrer un commentaire