Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 角度指令传递功能/提升事件_Javascript_Angularjs_Angularjs Directive - Fatal编程技术网

Javascript 角度指令传递功能/提升事件

Javascript 角度指令传递功能/提升事件,javascript,angularjs,angularjs-directive,Javascript,Angularjs,Angularjs Directive,我一直在将一个遗留项目升级到angular。我使用dhtmlxgrid创建了一个指令 angular.module('amod', []).directive('dxGrid', function() { return { restrict: 'A', scope: false, transclude: true, template: '<div ng-transclude></div>', link: function($sc

我一直在将一个遗留项目升级到angular。我使用dhtmlxgrid创建了一个指令

angular.module('amod', []).directive('dxGrid', function() {

return {
    restrict: 'A',
    scope: false,
    transclude: true,
    template: '<div ng-transclude></div>',

    link: function($scope, $element, $attrs, $controller) {

        $scope.$watch($attrs.data, function(xmlData) {
            mygrid.clearAll();
            mygrid.loadXMLString(xmlData); 
         mygrid
        });


        //init grid
        var mygrid = new dhtmlXGridObject($element[0]);


    }

  };
});

最后,我想做的是,每当选择一行时,在控制器上运行一个函数,并且能够将一行传递给指令。

因为您没有使用隔离作用域,所以应该能够从事件处理程序调用控制器函数:
$scope.controllerFunction(row)
。关于“还可以将一行传递给指令”,您需要澄清您在这里的意思,这可能应该在一个单独的问题中提出。由于您没有使用隔离作用域,您应该能够从事件处理程序调用控制器函数:
$scope.controllerFunction(row)
。关于“还可以连续传递给指令”,您需要澄清您的意思,这可能应该在单独的问题中提出。
angular.module('amod', []).directive('dxGrid', function() {

return {
    restrict: 'A',
    scope: false,
    transclude: true,
    template: '<div ng-transclude></div>',

    link: function($scope, $element, $attrs, $controller) {

        $scope.$watch($attrs.data, function(xmlData) {
            mygrid.clearAll();
            mygrid.loadXMLString(xmlData); 
         mygrid
        });


        //init grid
        var mygrid = new dhtmlXGridObject($element[0]);


    }

  };
});