如何将$ scope值拆分/过滤到两个不同的$ scopes?

时间:2016-06-19 15:44:02

标签: angularjs

我的$ scope.Company = 10个项目中有10个数据。我想将记录拆分为两个不同的范围($ scope.companyA和$ scope.companyB),然后我将这些记录绑定到级联下拉列表中。你有什么主意吗 ?我怎样才能做到这一点?

我的记录如下: -

我的记录如下: -

ColA   ColB  ColC
A       AA    NULL
B       A      Test
C       B      Test2

1 个答案:

答案 0 :(得分:0)

我认为你有一个数组,你想将它分成2个数组。

$scope.company = [ 
    { "Value": "03190F10", "ParentValue": "", "displayValue": "School" }, 
    { "Value": "32CFC4C7", "ParentValue": "79CF4F14", "displayValue": "Service" }, 
    { "Value": "360A3825", "ParentValue": "32CFC4C7", "displayValue": "ticket" },
    { "Value": "79CF4F14", "ParentValue": "03190F10", "displayValue": "Customer" }, 
    { "Value": "Blank", "ParentValue": "", "displayValue": "(Select)" }];

$scope.company2 = $scope.company.slice(0, parseInt($scope.company.length / 2)); // take first half
$scope.company3 = $scope.company.slice(parseInt($scope.company.length / 2), $scope.company.length); // take second half