I'm trying to create an AngularJS directive that calls a service created using $resource with the value of the attribute in the template and makes the result available in the scope of the element.
I have a very simple service:
services.factory('Concept', ['$resource', function($resource) {
return $resource('http://example/api/:id');
}]);
And a directive:
directives.directive('anConcept', ['Concept', function(Concept) {
return {
scope: {
anConcept: '@'
},
restrict: 'A',
controller: function($scope, $element) {
$scope.results = Concept.get({id: concept});
}
}
}]);
I then try to invoke this in my view:
<div an-concept="1">
{{results}}
</div>
Looking at the network pane in my browser's debugger I can see the requests getting made, but the result isn't being made available in the scope of the element.
I'm sure I'm making a very basic mistake but I can't figure out what it is.