尝试使用语义UI和angularJS执行ng-change



我正在尝试使用以下代码加载带有angularjs和语义UI的下拉列表

<div id="state" class="ui search selection dropdown">
<label for="state">Estado</label>
<input type="hidden" name="state">
<i class="dropdown icon"></i>
<div class="default text">Selecione o Estado</div>
<div class="menu" ng-model="state" ng-change="loadCity()">
<div ng-repeat="state in states" class="item" data-value="{{state.ID}}">{{state.NAME}}</div>
</div>
</div>
<div>

但是不调用该事件。

当我使用下面的代码时,它可以工作:

<select id="state" class="ui search selection dropdown" ng-model="state" ng-init="loadState()" ng-change="loadCity(state.ID)">
<option ng-repeat="state in states" value="{{state.ID}}">{{state.NAME}}</option>
</select>

我做错了什么?

看起来这是其他人遇到的问题。看看这个问题: https://github.com/Semantic-Org/Semantic-UI/issues/1913

我找到了一种使用一些 1.3 魔法在角度侧解决这个问题的方法。这不是最好的方法,但它有效。

它可以通过使用formController和手表简单地解决。 我更新了 plnkr。请注意,我使用下划线.js来查找窗体中控件的数组索引。

其余的都是纯角度的,还有一些jquery。

http://plnkr.co/edit/eDOej3zJ0bwQ1xyX1LDI?p=preview

查看以下部分: app.directive('select'

最新更新