show popover on input validation in angularjs -
i want input validation in angularjs. showing bootstrap popover(https://angular-ui.github.io/bootstrap/#/popover) on when invalid. cannot figure out how trigger popover.
user name: <input type="text" name="username" ng-model="user.name" popover="m here" popover-trigger="myform.username.$error.required" required>
the [plunker] : http://plnkr.co/edit/pwgquzxzhacvyekebc2o?p=preview
to trigger popover using custom conditions have use $tooltipprovider
by default can trigger popover : mouseenter, mouseleave, click, focus,blur
so have define custom triggers, shown here : http://plnkr.co/edit/0weqzz?p=preview
angular.module('myapp',['ui.bootstrap']) .config(['$tooltipprovider', function($tooltipprovider){ $tooltipprovider.settriggers({'customevent': 'customevent'}); }]); angular.module('myapp').controller('mycontroller', ['$scope','$timeout', function($scope, $timeout) { $scope.firecustomevent = function() { $timeout(function() { $('#tooltiptarget').trigger('customevent'); }, 0); } }]);
Comments
Post a Comment