我有一个下拉列表(选择,选项),并使用动态填充选项ng-repeat
.我想$scope
在更改选项时调用一个函数.这是HTML
<div class="type-style" ng-show="accountCount > 3">
<select class="account-filter">
<option ng-repeat="account in getCustomerName() track by $index" ng-class="(account | limitTo: 18)" ng-bind="account.split('|')[0]"></option>
</select>
</div>
Run Code Online (Sandbox Code Playgroud)
我知道我们可以使用ng-change
,但ng-change
需要ng-model
,我不认为ng-model
在我的情况下是需要的.有人可以帮忙吗?
正如您在代码中注意到的那样,我正在对选项标签执行ng-repeat.那么我会在select标签中获得我在ng-repeat中使用过的"帐户"吗?这样我可以在ng-model中使用它?
此外,每个帐户都是一个字符串,其中3个值以"|"分隔.当我在ng-change上调用函数时,我想用它传递第二个值.
例如:每个帐户都有名称| 号码| 2号.现在在ng-repeat中我只显示名称,因为你可以看到我在ng-bind中进行了分割.因此,如果我在select标签中使用ng-model,我将获得名称.但我希望数字作为参数传递给函数.