I have the following Angular controller with a simple http get in it:
angular.module('SCtrl', ['ng-fusioncharts']).controller('SCtrl', function($scope, $http) {
//Get All errors.
$http({
method: 'GET',
url: 'node/errors'
}).then(function successCallback(response) {
$scope.notifications = response.data;
console.log($scope.notifications);
}, function errorCallback(response) {
});
}
This works fine.
I then have the following directive. I want to be able to put {{notifications}} in the module body, however it doesn't work. I am guessing this is because I give the directive its own scope. What is the correct way to link scopes? My attempt is below but this doesn't work.
Thanks!
angular.module('SCtrl').directive('listDirective',function(){
return{
restrict:'E',
scope:{
listTitle:"@",
notifications:"="
},
templateUrl: '../templates/listWidget.html',
link: function(scope, element, attrs){
$scope.notifications=scope.notifications;
}
}
});
notificationsdirectly in yourlistWidget.html, you can just do<list-directive notifications="notifications"></list-directive>