I have to assigned a value to a $scope variable inside link function and this value has to be displayed in the UI.But, I am not able to display it on UI.
My code is as follows:
UI:
<div> {{articleContent}}</div>
Link function:
app.directive('member', function($compile,$http,getTocService) {
return {
restrict: "A",
replace: true,
scope: {
member: '=',
articleData: '=',
articleContent: '=',
articleDetails: '='
},
template: "<div><li ng-if='member.title'><a href='#' ng-click='getContent(member.itemId)'>{{member.title}}</a></li></div>",
link: function(scope, element, attrs) {
scope.getContent = function(itemId) {
getTocService.getArtData(itemId, function(data){
var articleDetails = data.data.getArticleResponse.articleDetail.articleContent;
scope.$parent.articleContent = articleDetails;
alert(articleDetails);
});
}
}
});
Controller:
app.controller('apdController', function($scope, getTocService,$location) {
var bookId = $location.search().id;
var sampdata = getTocService.getToc(bookId);
$scope.tasks =sampdata;
$scope.articleContent = '';
});
I want to display articleContent variable's data . Can someone help me please..
link. is it a directive's link?id="articleContent"is a view of directive or your main html?scopevariable in your main html. right?