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 ...

1

1 Answer 1

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">

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.