2

I have the following working code:

<input 
    value="order.value"
    name="orderValue"
    ng-pattern="/^[0-9]{0,20}$/"
    handle-save="update()">
</input>
<div 
    class="text-primary 
    icon-exclamation-sign" 
    ng-show="form.value.$error.pattern">
    Only numbers are allowed
</div>

Is it possible to trigger a bootstrap popover instead of "Only numbers are allowed"? It seems like it will only be triggered by a mouse click or hover ...

strivedi183
  • 4,749
  • 2
  • 31
  • 38
ux11
  • 158
  • 2
  • 13
  • 2
    Try with this question: [Enable angular-ui tooltip on custom events](http://stackoverflow.com/questions/16651227/enable-angular-ui-tooltip-on-custom-events/16653079#16653079). – Stewie Dec 17 '13 at 20:52

1 Answers1

3

For such interactions you can use a directive and in it scope.$watch to watch for changes of the 'shown' attribute and reflect them - call 'element.popover()'.

The directive will look something like this

directive('popover', function () {
  return {
    restrict: 'A',
    scope: {
      shown: '=',
    },
    link: function(scope, element) {
      scope.$watch('shown', function(shown) {
        if (shown) {
          element.popover('show');
        } else {
          element.popover('hide');
        }
      });
    }
  };
});

and you can use it like so <div popout shown="form.value.$error.pattern">

Tony
  • 1,785
  • 1
  • 11
  • 9