I have created a directive for auto focus on text box
(function () { 'use strict'; angular.module('commonModule').directive('srFocuson',function(){ return { restrict: 'A', require: 'ngModel', link: function (scope, element, attrs) { scope.$watch(attrs.focusMe, function (value) { if (value === true) { console.log('value=', value); element[0].focus(); scope[attrs.focusMe] = false; } }); } }; }); })(); And now i want to bind that directive to my text box.I have tried to bind to input field but its not working.
<input placeholder="SR ID, SSN/ITIN, or School ID" sr-focuson="focusMe" type="text" id="form_ID" name="searchId" autofocus data-ng-model="vm.searchCriteria.searchId" maxlength="20" class="form-control">