#StackBounty: #angularjs #typescript #angularjs-directive #ng-options Writing custom directive to add tooltips to ng-options in Angular…

Bounty: 50

I have some HTML that is currently populating a select box using the ng-options directive. Our problem is that ng-options doesn’t support using tooltips. To solve this, I am trying to write a custom directive but I am pretty new to AngularJS and TypeScript, so I’m not sure where to go from where I am.

Here is the relevant code so far:


    <select grid-column-tooltip class="select-box" id="availableColumn" size="5" 
                    ng-options="column as column.localizedTitle for column in vm.availableColumns | filter: vm.environmentMatches track by column.field" 
                    ng-model="vm.availableColumnElement" ng-dblclick="vm.moveToSelectedColumns()">
            <option value="" ng-if="false"></option>

There is a field on the column object called environmentLabel that I want to display as a tooltip upon hovering.


    module psfc {
    class GirdColumnTooltipDirective implements ng.IDirective {
        restrict = 'A';

        template = '
'; constructor( ) { } static directive = (): ng.IDirectiveFactory => { return () => new GirdColumnTooltipDirective(); } } angular .module('psfc') .directive('gridColumnTooltip', GirdColumnTooltipDirective.directive()); }

This is obviously very incomplete because I am unsure how to implement what I want in typescript. I am also unsure whether or not to make the template into a div that appears upon hovering, or finding a way to add the title attribute to the relevant option element.

Also, depending on what the solution is, I’m not worried about the CSS for now. I can fix any style problems later.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.