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

Using $resource AJAX in initiating controller #18

Open
abdollahkahne opened this issue May 25, 2019 · 1 comment
Open

Using $resource AJAX in initiating controller #18

abdollahkahne opened this issue May 25, 2019 · 1 comment

Comments

@abdollahkahne
Copy link

Unfortunately when I try to edit an existing exercise it cant load that in exercise template page, but after I editing code such as it return the promise and resolving the promise in init() function solve my problem. I think the code here really needs modification:

var init = function () {
          // We do not use the resolve property on the route to load exercise as we do it with workout.
          $scope.exercise = ExerciseBuilderService.startBuilding($routeParams.id);
      };

And Here:

 service.startBuilding = function (name) {
            //We are going to edit an existing exercise
            if (name) {
                buildingExercise = WorkoutService.Exercises.get({ id: name }, function (data) {
                    newExercise = false;
                });
            }
            else {
                buildingExercise = new Exercise({});
                newExercise = true;
            }
            return buildingExercise;
        };

we should consider using $promise and using it after resolution at init() function using then call back Function

@abdollahkahne
Copy link
Author

Altough due to this point that both of $scope.exercise and buildingExercise refrence to same object I think the above code is correct altough it doesnt refresh the template for me. What is the mechanism of dirty watch here? does every change to building exercise trigger digest cycle or the change should directly do at property level of $scope.exercise?
Thanks in advance

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

1 participant