I have one function defined in $rootScope which has some value. I have created one directive to show value from there. I am not getting any value there.
<last-data-update-message type="info" update-for='stats'></last-data-update-message>
$rootScope.Helpers = {
getLastUpdateStatus: function(type) {
if (!_.isEmpty(Helpers.lastUpdateDetails)) {
if (type == 'requests') {
return Helpers.lastUpdateDetails.last_request_generated;
} else if (type == "stats") {
return Helpers.lastUpdateDetails.last_stats_executed || ((new Date()).getTime() - 2 * 60 * 60 * 1000);
} else if (type == "response") {
return Helpers.lastUpdateDetails.last_response_recieved;
} else {
return Helpers.lastUpdateDetails.last_stats_executed || ((new Date()).getTime() - 2 * 60 * 60 * 1000);
}
}
}
}
mymodule.directive('lastDataUpdateMessage', ["$rootScope", '$compile', function($rootScope, $compile) {
return {
restrict: 'AE',
replace: true,
template: function(element, attrs) {
if (element && element[0]) {
var targetElem = element[0];
console.log(attrs)
console.log("type", attrs.type)
console.log("for", attrs.updateFor);
console.log(attrs.updateFor);
return '<div class="alert alert-info fade in margin-0" style="margin-top:10px !important">' +
'<i class="fa-fw fa fa-info"></i>' +
'<strong>Information!</strong> The below report relies on data that is computed in batch. The computaitons were last updated about <span am-time-ago="$rootScope.Helpers.getLastUpdateStatus(' + attrs.updateFor + ')"></span>.' +
'</div>';
}
},
link: function(element) {
}
}
Any help will be appreciated.
<span am-time-ago="Helpers.getLastUpdateStatus(' + attrs.updateFor + ')">and let me know if it worked