Angularjs ng更改不适用于自定义ui网格

Angularjs ng更改不适用于自定义ui网格,angularjs,Angularjs,在base.js中定义了一个自定义ui网格 app.directive('stkGrid', ['$window', '$timeout', function($window, $timeout) { return { restrict: 'E', transclude: true, scope: { data: '=', autoHeight: '=',

在base.js中定义了一个自定义ui网格

app.directive('stkGrid', ['$window', '$timeout', function($window, $timeout) {
    return {
        restrict: 'E',
        transclude: true,       
        scope: {
            data: '=',
            autoHeight: '=',
            selectionVariable: '=',
            onRowSelect: '&',
            onRowDeselect: '&',
            onRowsChanged: '&',
            selectAll: '@',
            canSelect: '@',
            columnDefs: '=',
            multiSelect: '@',
            noUnselect: '@'
        },
        controllerAs: 'parentCtrl',
        controller: ['$scope', '$element', function($scope, $element) {
            var $attrs = $element[0].attributes;

            $scope.$watch('selectionVariable', function(newValue, oldValue) {
                if (!newValue || !newValue.length) {
                    //$scope.gridApi.selection.clearSelectedRows();
                }
            });

            function rowSelectionChanged(row) {
                // row selection logic
            };

            $scope.stkGridOptions = {
                data: 'data',
                enableRowSelection: ($scope.canSelect != 'false'),
                enableSelectAll: ($scope.selectAll == 'true'),
                multiSelect: ($scope.multiSelect == 'true'),
                noUnselect: (typeof $scope.noUnselect !== 'undefined'),
                enableFullRowSelection: true,
                selectionRowHeaderWidth: 0,
                rowHeight:25,
                onRegisterApi: function(gridApi) {
                    $scope.gridApi=gridApi;
                    if ($scope.autoHeight) {
                        //var height=$window.innerHeight+$scope.autoHeight+'px';
                        var height=$scope.autoHeight+'px';
                        $element.css('height',height);
                        angular.element($element.children()[0]).css('height',height);
                        $timeout(function() {$scope.gridApi.core.handleWindowResize();});
                    }
                    $timeout(function() {gridApi.core.handleWindowResize();});
                    if (rowSelectionChanged) {
                        gridApi.selection.on.rowSelectionChanged($scope, rowSelectionChanged);
                        gridApi.selection.on.rowSelectionChangedBatch($scope, rowSelectionChanged);
                    }
                },
                columnDefs: (!!$scope.columnDefs ? $scope.columnDefs : [])
            };

            this.addColumn=function(col) {
                if (!!$scope.columnDefs) {
                    return;
                }

                $scope.stkGridOptions.columnDefs.push(col);
            };

            $scope.$watchCollection("columnDefs", function(newColumnDefs) {
                if (!newColumnDefs) {
                    return;
                }

                $scope.stkGridOptions.columnDefs = newColumnDefs;
            });
        }],
        link: function($scope, $element, $attrs) {
            if ($scope.autoHeight) {
                angular.element($window).bind('resize', function () {
                    //var height=$window.innerHeight+$scope.autoHeight+'px';
                    var height=$scope.autoHeight+'px';
                    $element.css('height',height);
                    angular.element($element.children()[0]).css('height',height);
                    $timeout(function() {$scope.gridApi.core.handleWindowResize();});
                });
            }
        },
        template: '<div ui-grid="stkGridOptions" ui-grid-selection></div><div ng-transclude></div>'
    };
}]).directive('stkCol', function() {
    return {
        require: '^^stkGrid',
        restrict: 'E',
        transclude: false,
        scope: {
            field: '@',
            displayName: '@',
            width: '@',
            maxWidth: '@',
            minWidth: '@',
            cellFilter: '@',
            cellClass: '@',
            cellTemplate: '=',
            type: '@',
            formatter: '&'
        },
        link: function(scope, element, attrs, stkGridCtrl) {
            stkGridCtrl.addColumn(scope);
        }
    };
});
任何关于为什么控制器中的ng更改不起作用或如何添加更改功能的想法都会非常有用。

ng change=“changeDocType()”将在stkGrid指令(隔离作用域)中查找该方法,而不是home.js中的作用域

ng-change="grid.appScope.changeDocType()"
文件:

vm.documentFieldTemplates = {
        'include': '<input type="checkbox" ng-model="row.entity.include" />',
        'fileName': '<span ng-class="{inactive: !row.entity.include}">{{row.entity.fileName}}</span>',
        'typeAbbreviation': '<select class="form-control" ng-options="docType.DOCUMENT_TYPE_ABBREVIATION as docType.DOCUMENT_TYPE_ABBREVIATION for docType in grid.appScope.$parent.batchCtrl.docTypes" ng-model="row.entity.typeAbbreviation" ng-disabled="!row.entity.include" ng-change="changeDocType()"><option value="">&lt;Select Document Type&gt;</option></select>',
        'amount': '<input type="text" ng-model="row.entity.amount" ng-disabled="true"/>'
    };
$scope.changeDocType = function(){
        alert("Document Type Changed!");
    }
ng-change="grid.appScope.changeDocType()"