I am calling data from an object which is in the main controller. And it is displaying perfectly fine. I have a requirement now which I have to move the object in the directive's link function, and still render it the way it was rendering before.
Here is the main HTML code.
<cs-tooltip id="cs-tooltip" testingtooltip="firsttooltip" testfunc="secondBut()" ng-show="showtooltip"></cs-tooltip>
Here is the templateUrl code of the directive:
<div id="cs-tooltip-title">{{testingtooltip.title}}</div>
And here is an example of the object that I have:
$scope.firsttooltip = {
content: 'Score derived. Score derived. Score derived. Score derived. Score derived. Score derived. Score derived. Score derived. ',
title: "Threat Score",
}
The object I am using is pretty complex, I have just simplified it here for understanding the concept. I am trying to make a link function in the directive like this and the data doesn't show up.
link: function($scope){
//the same object here
}
Without more details I can only think of a problem that can be fixed with timeout.
If you have a directive scope:
scope: {
testingtooltip: '='
}
In the link function you can try:
link: function($scope, $timeout){
$timeout(function() {
console.log($scope.testingtooltip);
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.