var param1;
// ...
.then(function(p1) {
param1 = p1;
// ...
return Promise;
})
.then(function(param2) {
console.log(param1, param2);
})
app.controller('PhoneCntrl', ['$scope', '$routeParams', function($scope, $routeParams){
$http.get('phones/' + $routeParams.phoneId + '.json').success(function(data) {
$scope.phone = data;
});
$scope.phoneId = $routeParams.phoneId;
}]);
def index
@places = Place.where(user: current_user)
end
function GunService ($rootScope){
this.onGunAdded = function (callback){
return $rootScope.$on(GunService.events.ADDED, callback);
};
this.publish = function (params){
// do your thing ...
.then(function (newGun){
$rootScope.$emit(GunService.events.ADDED, newGun);
});
}
}
GunService.events = {
ADDED: 'GunService.added'
};
function SomeController(GunService) {
GunService.onGunAdded(gunAdded);
this.add = function (){
// do your thing
}
function gunAdded(newGun) {
// Use newly created gun or do .posts
}
}