I'm constructing elements from metadata and i need to set a calculated class for each element.
This is what I currently do,
var promisses =_.map(templates, function (tmpl) {
return $http.get(tmpl.template, {
cache : $templateCache,
// Generated class name is carried to the resolving function using the config
classes : scope.generate_class(tmpl.columns)
}).then(function (data) {
if ( data.status != 200 )
throw new Error('Failed to fetch template');
var elm = angular.element(data.data);
elm.addClass(data.config.classes);
return elm;
});
});
$q.all(promisses).success....
If I want to use success instead of then fir the $http bit (which evaluates in case of an error as well) how would i do that ? when using success the config is not carried on to the resolving function (only the data).
Thanks.
.successhere since it doesn't chain well.