This example is taken from angularjs's docs
<form name="myForm" ng-controller="Ctrl">
userType: <input name="input" ng-model="userType" required>
<span class="error" ng-show="myForm.input.$error.required">Required!</span>
</form>
I want to achieve the same behavior but with a Bootstrap tooltip. I've looked at the Angular UI-Bootstraped project (http://angular-ui.github.io/bootstrap/) but can't figure out how to do this.
Something like:
<input type="text" value="Click me!"
tooltip="See? Now click away..."
tooltip-trigger="focus"
tooltip-placement="right"
tooltip-enabled="myForm.input.$error.required" <--- pseudo code
/>
I've tried several ways, looks like you only can modify source code from angular-bootstrap to get a proper solution. But. There is a 'hacky' solution, maybe it'll help you or even that's what you needed(examples from angular-bootstrap and angular-input combined):
<form name="myForm" class="my-form">
userType: <input style="width: 50px;" name="input" ng-model="userType" required value="Click me!" tooltip="{{myForm.$valid ? '' : 'See? Now click away...'}}" tooltip-trigger="focus" tooltip-placement="right" class="form-control">
<span class="error" ng-show="myForm.input.$error.required">Required!</span><br>
<tt>userType = {{userType}}</tt><br>
<tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br>
<tt>myForm.input.$error = {{myForm.input.$error}}</tt><br>
<tt>myForm.$valid = {{myForm.$valid}}</tt><br>
<tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br>
</form>
same in plunker.
basically here you just remove text from tooltip and it hides.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With