conditional dynamic tooltips (directives)

1,266 views
Skip to first unread message

Matjaž Lipuš

unread,
Mar 27, 2014, 7:56:55 AM3/27/14
to ang...@googlegroups.com
Depending of one directive logic I want conditionally add tooltip
  • I use 3rd party tooltip directive
  • add tooltip only if some condition is met
  • do not initialise tooltip directive if it's not necessary

I want to dynamically add tooltip (or any other directive) ONLY IF condition is met.

Matjaž Lipuš

unread,
Mar 27, 2014, 9:56:23 AM3/27/14
to ang...@googlegroups.com
I have created an alternative with $compile/priority/terminal


Which one do you prefer and is there a better way?

Justin Walsh

unread,
Mar 28, 2014, 3:09:25 AM3/28/14
to ang...@googlegroups.com
Hi Matjaz

I prefer the plunkr with the more expressive HTML, i.e.

    <div ng-repeat="item in items">
       <div custom-text="item.text" class="item"></div>
    </div>

... since the intent is clearer whjen you read the HTML
I believe you could simplify this slightly though - do you really need the compile function?

To take it a step further, if your intent is just to add a conditional tooltip, wouldn't a custom-tooltip directive be more expressive? 
.. but perhaps the experts can help out here .. see http://plnkr.co/edit/yRyJfizz5TusTRI9Hr7V?p=preview

Matjaž Lipuš

unread,
Mar 28, 2014, 4:39:56 AM3/28/14
to ang...@googlegroups.com
Hi Justin,

I want conditional directives (tooltips) inside other directive. As plnks shows.

I used $compile because I don't know how can I otherwise add dynamic directive?

Thanks for the plunk, I have tweaked it so I can read text: http://plnkr.co/edit/qN1OCgP8mGn0dlOhB5BK?p=preview

But again, how can I conditionally add ui.bootstrap.tooltip directive?
Reply all
Reply to author
Forward
0 new messages