This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var q1 = $scope.q1 = $q.defer() | |
var q2 = $scope.q2 = $q.defer() | |
var p1 = $scope.q1.promise | |
var p2 = $scope.q2.promise | |
$q.all([ | |
p1.then(function(value){console.log('p1 resolved ', value); | |
return value;}), | |
p2.then(function(value){console.log('p2 resolved ', value); | |
return value;}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//opt 1 | |
SomeService.getStuff().then(function(stuff){ | |
return SomeService.manipulateStuff(stuff); | |
}).then(function(manipulatedStuff){ | |
//do stuff... | |
}); | |
//opt 2 | |
SomeService.getStuff().then(SomeService.manipulateStuff).then(function(manipulatedStuff){ | |
//do stuff... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.addToResponses = function(responses, interventionId, questiongroupId, questiongroupInstanceId, questionId, response) { | |
if (!responses.questiongroups) { | |
responses.interventionId = interventionId | |
responses.questiongroups = new Array() | |
} | |
if(!responses.questiongroups[????????]) { | |
responses.questiongroups.push({Id: questiongroupId, questiongroupInstances:{}}) | |
} | |
if (!responses.questiongroups[????????].questiongroupInstances[questiongroupInstanceId]){ | |
responses.questiongroups[????????].questiongroupInstances.push({Id: questiongroupInstanceId, questions:{}}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getSomeThings().then(function(things){ | |
return things.map(function(aThing){ | |
return OtherThing.find(aThing.id); | |
}); | |
}); | |
//Replaces | |
var thingIx, newThing, otherThings | |
getSomeThings() | |
.then(function(collection){ |