2

I'm tying to understand how I can have a conditional promise, without repeating everything inside the .then function again.

For example:

if (cameraFilmType == "Standard")

Then I don't want to call the addImageFilter function

if (cameraFilmType == "Vintage")

Then i do want to call the addimageFilter function.

I still want to run everything inside the .then in both cases, but i need the option to use .then as the addImageFilter function is async. How can i do this without repeating the code in .then twice?

    factory.addImageFilter(imageData, cameraFilmType).then(function (newImg) {
        $scope.imageData = newImg;
        //Do loads of stuff
    });
Ali_bean
  • 341
  • 3
  • 14

0 Answers0