Skip to content

Using $resource AJAX in initiating controller #18

@abdollahkahne

Description

@abdollahkahne

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions