Last active
August 29, 2015 13:57
-
-
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?
This file contains 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 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