I'm trying to disable the mouse-wheel for a number input that gets created as part of an ng-repeat block by using a directive. Currently I'm trying to dynamically assign an id to the input element using ng-attr-id (see below), which seems to work. I then try and pass the dynamic id info to the directive, which also seems to work (the console log message prints the correct id when the directive is called), however, if I dig down into the HTML in developer mode, it looks like the id for the input inside of ng-repeat doesn't actually get generated from the ng-attr-id definition until after the directive has been called, so when it tries to look up the dynamic ID it doesn't find it(?) Can anyone steer me in the right direction?
Here is the HTML:
<div ng-repeat tgen in tgen_list>
<div id="tgenNum" style="padding-bottom: 40px">
<label class="form-label-top2" style="float: left; margin-top: 5px; margin-bottom: 5px; margin-left:55px" for="number_tgenelems">
<font size="2">
<b>
Total Number Traffic Generator Ports:
</b>
</font>
</label>
<input type="number" type="submit" class="rf-form-control-sm" onkeydown="return false" ng-attr-id="{{ 'tgentgen_num' + $index }}" name="tgen_num" min="0" max="10" ng-click="addRemoveTgenTgen($index, elem.current_total_tgen_ports, elem.tgen_spinner_val)" ng-model="elem.tgen_spinner_val" style='width: 50px; float: left; margin-top: 12px; margin-left: 25px' />
</div>
<disable-mouse-wheel id-name="tgentgen_num" id-index="$index"></disable-mouse-wheel>
</div>
And this is the directive:
angular.module('csvApp').directive('disableMouseWheel', function () {
return {
restrict: 'E',
scope: {
idName: '@',
idIndex: '='
},
template:'',
link: function(scope, element, attrs){
console.log(scope.idName+scope.idIndex.toString())
numtgen_elem = document.getElementById(scope.idName+scope.idIndex.toString());
numtgen_elem.addEventListener("mousewheel", function(event){ this.blur() });
}
};
})