ng-click 在 IE 中不起作用,但在 CHROME 中工作正常

2023-12-27

<select id="from" multiple="multiple" name="list" ng-model="selectedVal">
    <optgroup label= "{{geo.Geo}}" ng-repeat="geo in Geographies"> 
        <option id="{{country.CountryKey}}" ng-repeat="country in geo.Country" ng-click="arrayPush()">{{country.CountryDescription}}</option>   
    </optgroup>
</select>

当我单击特定选项时,未调用 arrayPush()

$scope.arrayPush = function(){alert("Hello!");}

我刚刚找到了我的问题的答案

<select id="from" multiple="multiple" name="list" ng-model="selectedVal" ng-change="arrayPush()">
    <optgroup label= "{{geo.Geo}}" ng-repeat="geo in Geographies"> 
        <option id="{{country.CountryKey}}" ng-repeat="country in geo.Country" >{{country.CountryDescription}}</option>   
    </optgroup>
</select>

不要在选项中使用 ng-click,而是在选择中使用 ng-model 和 ng-change。适用于 Chrome 和 IE

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ng-click 在 IE 中不起作用,但在 CHROME 中工作正常 的相关文章