更改所选项目时,ng-change不起作用

时间:2015-06-05 15:39:15

标签: angularjs

我是棱角分明的新手,我试图显示级联下拉列表。这是我的HTML代码

<div class="row" ng-controller="createCabsTicketController as tktCreatecabsCntrl">

    <select id="LocalCompanyIDForSearch" ng-change="getIXs()" ng-model="createCabsTicket.cabsCompanies.selected" name="LocalCompanyIDForSearch" class="form-control" style="width:100%;">
                <option value=" "> </option>
                <option ng-repeat="localCompany in createCabsTicket.cabsCompanies"
                        value="{{ localCompany.CompanyID }}">
                    {{ localCompany.LongDescription }}
                </option>
            </select>
    <select id="IXCname" name="IXCname" class="form-control" style="width:100%;">
                <option value=" "> </option>
                <option ng-repeat="ix in createCabsTicket.IXCarrierNames"
                        value="{{ ix.Interexchange }}">
                    {{ ix.Interexchange }}
                </option>
            </select>

这是我的js文件内容

app.controller('createCabsTicketController',['$scope','$http',function($scope,$http){
    $scope.createCabsTicket = {
        cabsCompanies: [],
        IXCarrierNames: [],
        IXCarrierIds:[]
    };
    $http.get('http://localhost:52377/api/reference/companies/active', { cache: true }).success(function (data) {
        $scope.createCabsTicket.cabsCompanies = data;
    });
    $scope.getIXs = function (selectedItem) {
        var postData = { ActiveOnly: true, CompanyId: selectedItem, CarrierId: "", CarrierName: "", CarrierType: "" };
        $http.post('http://localhost:52377/api/reference/interexchanges', postData, { cache: true }).success(function (data) {
            $scope.createCabsTicket.IXCarrierNames = data;
        });
    }
}]);

Web服务工作和父列表填充得很好。但是ng-change事件不会被解雇。我不确定我做错了什么。我找到了类似的帖子,但他们对解决我的问题没什么帮助。请帮忙!!

0 个答案:

没有答案