1
我有两个列表,我concat他们没有重复的vlaue,我这样做,所以我有重复价值,为什么......?联合清单没有重复
在我的HTML:
..
<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>
..
在我的JS
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;
};
}]);
THX
“平台”的后期示例。 – dfsq 2014-11-05 15:11:41
@dfsq我发布平台的例子 – Mercer 2014-11-05 15:16:59