I am having an issue where the ternary operator for the glyphicon class switching works just fine but doesn't seem to work on my custom tooltip directive. It just stays with the default Add Project
and won't switch to Update Project
. It obviously has something to do with my custom directive. Do I need to force a $digest
cycle or add a $watch
? I'm relatively new to Angular and would greatly appreciate some assistance on this one.
HTML:
<span class="glyphicon glyphicon-{{ currentproject ? 'arrow-up' : 'plus'}}"
ng-click="PostProject(currentproject)"
tooltip="{{ currentproject ? 'Update' : 'Add'}} Project">
</span>
Custom Directive:
app.directive('tooltip', function () {
return {
restrict: 'A',
scope: {
tooltip: '@'
},
link: function ($scope, element, attrs, ctrl) {
$(element).tooltip({
title: $scope.tooltip
});
}
};
});