-1
我有兩個包含相同元素以及不同元素的列表。如何從這兩個列表中列出一個列表並激發我的共同點和新項目。?從兩個列表中創建一個列表
...
<list-of-items items="application.units"
label="$item.name"
selected-item="unit"
selectable="true"
onedit="on_edit_unit($item)"
editable="false"
size="small">
</list-of-items>
<list-of-items items="applicationCible.units"
label="$item.name"
selected-item="unit"
selectable="true"
onedit="on_edit_unit($item)"
editable="false"
size="small">
</list-of-items>
...
UPDATE:
在我的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) {
...
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。要做到這一點
做喲要合併呢? – 2014-11-05 13:51:47
@MajoB是的正是我想要合併它們 – Mercer 2014-11-05 13:52:30
你可以使用application.units.concat(applicationCible.units) – 2014-11-05 13:53:46