Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/395.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 来自外部控制器的指令的angularjs访问链接功能_Javascript_Angularjs_Angularjs Directive_Angularjs Service - Fatal编程技术网

Javascript 来自外部控制器的指令的angularjs访问链接功能

Javascript 来自外部控制器的指令的angularjs访问链接功能,javascript,angularjs,angularjs-directive,angularjs-service,Javascript,Angularjs,Angularjs Directive,Angularjs Service,我在模板中有两个ng include,但类似: 我需要刷新控制器ctrTable中的表,但按钮在控制器中,并调用控制器ctrButton中的服务tableService函数,该表是一个指令 ctrTable.js Handelbay.directive('ngJqgrid',[ '$window', function ($window) { return { restrict: 'E', replace: true, scope: { config:

我在模板中有两个
ng include
,但类似:


我需要刷新控制器
ctrTable
中的表,但按钮在控制器中,并调用控制器
ctrButton
中的服务
tableService
函数,该表是一个指令

ctrTable.js

Handelbay.directive('ngJqgrid',[ '$window', function ($window) {
return {
    restrict: 'E',
    replace: true,
    scope: {
        config: '=',
        api: '=?',
    },
    link: function (scope, element, attrs) {
        var table, div;
        scope.$watch('config', function (value) {
            table.jqGrid(value);
            scope.api = {
                refresh: function () {
                    table
                        .jqGrid('clearGridData')
                        .jqGrid('setGridParam', { data: scope.modeldata })
                        .trigger('reloadGrid');
                }
            };
        });
    }
}; }]);
Handelbay.factory("$tableService", ['$rootScope','$http',function($rootScope,$http) {

return { refresh: function(){ /* refresh ??? */ } } }]);
$scope.jqconfig={
url:Metronic.getAJAXURL()+“/ajax/getNames”,
数据类型:“json”,
姓名:[
“id”,
“姓名”
],
宽度:空,
shrinkToFit:错,
colModel:[
{name:'name',index:'name',autowidth:true,shrinkToFit:true},{name:'id',index:'id',autowidth:true,shrinkToFit:true}
],
sortname:'id',
};
ctrButton.js

Handelbay.directive('ngJqgrid',[ '$window', function ($window) {
return {
    restrict: 'E',
    replace: true,
    scope: {
        config: '=',
        api: '=?',
    },
    link: function (scope, element, attrs) {
        var table, div;
        scope.$watch('config', function (value) {
            table.jqGrid(value);
            scope.api = {
                refresh: function () {
                    table
                        .jqGrid('clearGridData')
                        .jqGrid('setGridParam', { data: scope.modeldata })
                        .trigger('reloadGrid');
                }
            };
        });
    }
}; }]);
Handelbay.factory("$tableService", ['$rootScope','$http',function($rootScope,$http) {

return { refresh: function(){ /* refresh ??? */ } } }]);
$scope.refresht=function(){$tableService.refresh();}
modal.html

<ng-jqgrid config="jqconfig" addnew="true" modeldata="patientdata" gridid="patientgrid" pagerid="patientpager" api="gridapi"></ng-jqgrid>
<input type="button" ng-click="refresht()" />
Handelbay.directive('ngJqgrid',[ '$window', function ($window) {
return {
    restrict: 'E',
    replace: true,
    scope: {
        config: '=',
        api: '=?',
    },
    link: function (scope, element, attrs) {
        var table, div;
        scope.$watch('config', function (value) {
            table.jqGrid(value);
            scope.api = {
                refresh: function () {
                    table
                        .jqGrid('clearGridData')
                        .jqGrid('setGridParam', { data: scope.modeldata })
                        .trigger('reloadGrid');
                }
            };
        });
    }
}; }]);
TableService.js

Handelbay.directive('ngJqgrid',[ '$window', function ($window) {
return {
    restrict: 'E',
    replace: true,
    scope: {
        config: '=',
        api: '=?',
    },
    link: function (scope, element, attrs) {
        var table, div;
        scope.$watch('config', function (value) {
            table.jqGrid(value);
            scope.api = {
                refresh: function () {
                    table
                        .jqGrid('clearGridData')
                        .jqGrid('setGridParam', { data: scope.modeldata })
                        .trigger('reloadGrid');
                }
            };
        });
    }
}; }]);
Handelbay.factory("$tableService", ['$rootScope','$http',function($rootScope,$http) {

return { refresh: function(){ /* refresh ??? */ } } }]);

那些是情态动词还是部分动词?您可以将其中一个的代码包含到另一个中(即modal.html中包含modal2的ng include),并通过DOM访问它。要通过JS访问它,您应该使用指令/组件绑定(您在指令中看到的“@”、“=”、“&”等)是modals还是partials?您可以将其中一个的代码包含到另一个中(即modal.html中包含modal2的ng include),并通过DOM访问它。要通过JS访问它,您应该使用指令/组件绑定(您在指令中看到的“@”、“=”、“&”等)