Prasad Shigwan Prasad Shigwan - 2 months ago 19
Javascript Question

ng-click not working in IE on option select angularjs

I'm using following HTML code
HTML:

<select style="width: 100%" name="multipleSelect" id="multipleSelect" ng-model="data.multipleSelect" multiple>
<option ng-click="BRPTab.AddFilesToOpenorDelete(fileName)" ng-repeat="fileName in BRPTab.FileNames">{{fileName}}</option>
</select>


Here BRPTab is an Alias.

Script code:

scope.AddFilesToOpenorDelete = function (FileName) {
scope.SelectedFiles = [];
var request = { FileName: FileName };
scope.SelectedFiles.push(request);
}


This is working fine in Chrome but not in IE. Please suggest.

Answer

ng-click on options tag would not work. Do use ng-options directive then, that would make you code more cleaner.

<select style="width: 100%" name="multipleSelect" id="multipleSelect" 
  ng-model="data.multipleSelect" multiple 
  ng-options="fileName in BRPTab.FileNames"
  ng-change="BRPTab.AddFilesToOpenorDelete(data.multipleSelect)">
</select>