Greg Greg - 3 months ago 9
AngularJS Question

Skip object in ng-repeat

I have a table with column

names
and a second column with a list of all the names but the tricky part is that each list in the row should skip the name from the first row:

Ex:

Name 1 ---- (Name 2, Name 3)

Name 2 ---- (Name 1, Name 3)

Name 3 ---- (Name 1, Name 2)

I've tried:

<md-select ng-model="selectedTopology" multiple>
<md-option ng-repeat="(k,types) in networkTypes | filter: { name: !networkTypes[k].name } ">{{types.name}}</md-option>
</md-select>


This however leaves the list blank, but if I change my filter to:

filter: { name: networkTypes[k].name }


This shows only the name from the first column

Edit:

Structure

$scope.networkTypes = [
{
name: 'Networktype 1'
},
{
name: 'Networktype 2'
},
{
name: 'Networktype 3'
}
];

Answer

have you tried this :

<md-select ng-model="selectedTopology" multiple>
   <md-option ng-repeat="(k,types) in networkTypes" ng-if="types.name !== networkTypes[k].name">{{types.name}}</md-option>
</md-select>