我尝试使用 data-ng-change="GrowerCtrl()" 但我的控制器没有被调用?
任何帮助是极大的赞赏!
编辑 我已经添加了 html 和 javascript 的代码......我正在使用 Angular/Restangular 和 Select2
HTML
<html ng-app="MainPage">
<head>
***JS includes
</head>
<div ng-controller="AgenciesCtrl">
<div id="divAgency" class="MenuItemDiv">
<label id="lblAgencyName" class="HeaderLabel">Select agency...</label>
<select id="AgencyName" ng-model="SelectedAgency" ui-select2 chosen style="width:250px" ng-options="Agency.AgencyName for Agency in Agencies.AgencyList" data-ng-change="GrowerCtrl()">
@*<option ng-repeat="Agency in Agencies.AgencyList" >{{Agency.AgencyName}}</option>*@
</select>
</div>
</div>
<div ng-controller="GrowerCtrl">
<div id="divGrowers" class="MenuItemDiv">
<label id="lblGrowers" class="HeaderLabel">Select grower...</label>
<select id="Growers" ui-select2 chosen style="width:250px; padding:3px 3px 3px 3px; " ng-options="Grower.GrowerName for Grower in Growers.GrowerList |filter:SelectedAgency">
@*<option ng-repeat="Grower in Growers.GrowerList | filter:{SelectedAgency.AgencyID}" >{{Grower.GrowerName}}</option>*@
</select>
</div>
</div>
</div>
**文件/dialogControl.js
var FarmMapsApp = angular.module('MainPage', ['restangular']);
FarmMapsApp.directive('chosen', function () {
$("#AgencyName").select2();
$("#Growers").select2();
})
function AgenciesCtrl($scope, Restangular) {
Restangular.setBaseUrl('http://localhost/MappingServicesWebAPI/api');
Restangular.all('Agency');
$scope.Agencies = Restangular.all('Agency').getList();
};
**文件/GrowerList.js
function GrowerCtrl($scope, Restangular) {
Restangular.setBaseUrl('http://localhost/MappingServicesWebAPI/api');
Restangular.all('Grower');
$scope.Growers = Restangular.all('Grower').getList($('#AgencyName').val());
};