2014-11-05 14 views
1

두 개의 목록이 있습니다. 중복 된 vlue없이 연결됩니다. 그래서이 값을 복사합니다. 이유는 무엇입니까? 내 HTML에서중복되지 않은 concat 목록

: 내 JS에서

.. 
      <list-of-items items="platforms.concat(platformsCible).unique()" 
          label="$item" 
          selected-item="platform" 
          createfunction="add_platform($name)" 
          selectable="true" 
          editable="false" 
          size="small"> 
      </list-of-items> 
.. 

propertiesModule.controller('PropertiesCtrl', ['$scope', '$routeParams', 'PropertiesService', 'ApplicationService', 'PlatformService', 'Page', function ($scope, $routeParams, PropertiesService, ApplicationService, PlatformService, Page) { 
... 
    $scope.platforms = []; 

    /* Find all the platforms */ 
    PlatformService.get($routeParams.application, $routeParams.version).then(function(platforms){ 
     $scope.platforms = platforms; 
    }).then(function(){ 
     /* If platform was mentionned in the route, try to find it or add it */ 
     if($scope.platform) $scope.add_platform($scope.platform); 
    }); 

/* Find all the platforms cible */ 
if($routeParams.versionCible != null) { 
    PlatformService.get($routeParams.application, $routeParams.versionCible).then(function (platforms) { 
     $scope.platformsCible = platforms; 
    }).then(function() { 
     /* If platform was mentionned in the route, try to find it or add it */ 
     if ($scope.platformCible) $scope.add_platform($scope.platformCible); 
    }); 
} 

    Array.prototype.unique = function() { 
     var a = this.concat(); 
     for(var i=0; i<a.length; ++i) { 
      for(var j=i+1; j<a.length; ++j) { 
       if(a[i] === a[j]) 
        a.splice(j--, 1); 
      } 
     } 

     return a; 
    }; 

    }]); 

들으

+0

'플랫폼'의 예입니다. – dfsq

+0

@ dfsq 플랫폼 예보기 – Mercer

답변

0

시도 기본 각도 도구 사용하기 : angular.extend (DST를 , src); 경우에 따라 각도가 확장됩니다 (플랫폼, 플랫폼 가능)

객체를 비교하려고하지는 않습니다. 키 - 값 쌍만 비교하므로 고유 한 플랫폼의 연결 목록을 얻을 수 있습니다.

관련 문제