0

我正在使用简单的 angularjs 选择选项。一切正常,但 ng-change 不起作用。有什么具体原因吗?我试过用 $watch 和 'selectedParent' 。但这也不是开火。所以我猜选项更改没有发生。任何帮助为什么会这样?

HTML

<div class="col-md-12 n-p" ng-controller="PartStructureEditController">
    <div class="col-md-12 n-p pull-left">
        <div class="col-md-6">
            <label for="ToolDes">Parent Level / Part Number :</label><br />
            <select ng-options="object.combine as (object.Level + ' / ' + object.PartNo) for object in parentDropdown track by object.PartStructureId" ng-model="selectedParent"  ng-change="changeParent()" class="form-control">
            </select>
        </div>
    </div>
</div>

控制器

(function () {
    'use strict';
    MyApp.controller('PartStructureEditController', ['$rootScope', '$scope', 
       function ($rootScope, $scope) {
           function populateDropDown(data, ParentPartStructureId) {
               var result = [];
               data.map(function (a) {
                   if ((parseInt(a.ParentPartStructureId) !== ParentPartStructureId) || (parseInt(a.PartStructureId) !== ParentPartStructureId)) {
                       result.push(a);
                   }
               });
               $scope.parentDropdown = result;
               $scope.selectedParent = result[result.length - 1];
           }
           $scope.changeParent = function(){
                console.log('something');   
           }
       }]);
})();
4

0 回答 0