I am trying to understand how to pass data through my directive so that I can bind it at the view level. I believe I understand the separation of controller scope vs. the directive isolate scope but I cant seem to get a simple json result out to my view. My JSFiddle can be found here http://jsfiddle.net/jamesamuir/2KLVj/4/.
app.directive('testList', function (testService) {
return {
restrict: 'A',
link: function ($scope, element, attrs) {
$scope.name = 'isolate scope';
$scope.data = {};
$scope.data.loadtext = testService.getJSON().then(function (data) {
alert(data);
element.addClass("red");
});
}
}
});
It seems to me that this should work but, alas, it does not. Any help would be greatly appreciated.