Skip to content

Instantly share code, notes, and snippets.

@agektmr
Last active August 29, 2015 13:57
Show Gist options
  • Save agektmr/9407163 to your computer and use it in GitHub Desktop.
Save agektmr/9407163 to your computer and use it in GitHub Desktop.
I'm getting $promise as a result for fetching css using $resource. Does anyone know how to resolve?
var app = angular.module('app', ['ngResource']);
app.service('fetch', ['$resource', function() {
return $resource('css/:id/:file_name', {id: '@id'}, {
'get': {
method: 'GET',
params: {
file_name: 'style.css'
}
}
}
}]);
app.directive('directive', ['fetch', function(fetch) {
return {
controller: function($scope) {
$scope.click = function(id) {
fetch.get({id: id}, function(result) {
$scope.css = result; // <<< this guy becomes $promise
});
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment