在我们的一个项目中,我们正在尝试围绕 ngTable 库编写一个包装器!在这个组件的控制器中,我们使用ocLazyLoad加载ngTable。这是我们写的:
数据网格组件
(function() {
'use strict';
angular
.module('CommonApplication')
.component('datagrid', {
scope: true,
bindings: {
basepath: '@',
title: '@',
dataset: '<'
},
templateUrl: '/frontend/components/global/datagrid/templates/datagrid.html',
controller: 'DataGridController',
});
})();
带有 $ocLazyLoad 的 Datagrid 控制器(不起作用 :~| )
(function() {
'use strict';
angular
.module('CommonApplication')
.controller('DataGridController',
[ '$scope', '$injector', '$ocLazyLoad', DataGridController ]);
function DataGridController($scope, $injector, $ocLazyLoad) {
var vm = this;
var components = {
datagrid: [
'https://unpkg.com/ng-table@2.2.0/bundles/ng-table.min.css',
'https://unpkg.com/ng-table@2.2.0/bundles/ng-table.min.js'
]
};
$ocLazyLoad.load(components.datagrid).then(function() {
var NgTableParams = $injector.get('NgTableParams');
vm.data = [{name: "Moroni", age: 50},{name: "Moroni", age: 50},{name: "Moroni", age: 50},{name: "Moroni", age: 50}];
vm.tableParams = new NgTableParams({
page: 1,
count: 10
}, {
dataset: vm.data
});
});
}
})();
没有 $ocLazyLoad (Works) 的 Datagrid 控制器
(function() {
'use strict';
angular
.module('CommonApplication')
.controller('DataGridController',
[ '$scope', '$injector', '$ocLazyLoad', DataGridController ]);
function DataGridController($scope, $injector, $ocLazyLoad) {
var vm = this;
var components = {
datagrid: [
'https://unpkg.com/ng-table@2.2.0/bundles/ng-table.min.css',
'https://unpkg.com/ng-table@2.2.0/bundles/ng-table.min.js'
]
};
var NgTableParams = $injector.get('NgTableParams');
vm.data = [{name: "Moroni", age: 50},{name: "Moroni", age: 50},{name: "Moroni", age: 50},{name: "Moroni", age: 50}];
vm.tableParams = new NgTableParams({
page: 1,
count: 10
}, {
dataset: vm.data
});
}
})();
使用 ocLazyLoad,如果我在我们定义的行上设置断点,vm.tableParams
当它被new NgTableParams
设置和其他属性填充时,它们的属性中就会出现这个特定错误arguments
。
这是指向$ocLazyLoad.then
函数回调结束的异常错误!这是datagrid.js:47:7
因为我们将这些 js 文件和另一个文件连接到datagrid.js
:
TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.
at Function.remoteFunction (<anonymous>:3:14)
at http://localhost:8081/frontend/components/global/datagrid/datagrid.js:47:7
at http://localhost:8081/frontend/javascripts/head.min.js:136:20
at m.$eval (http://localhost:8081/frontend/javascripts/head.min.js:150:347)
at m.$digest (http://localhost:8081/frontend/javascripts/head.min.js:147:420)
at http://localhost:8081/frontend/javascripts/head.min.js:150:434
at e (http://localhost:8081/frontend/javascripts/head.min.js:50:444)
at http://localhost:8081/frontend/javascripts/head.min.js:53:300
对此有什么想法吗?!