angularjs ng-repeat filter not equal to

19,098

Solution 1

you should put your variable out of the quotes:

ng-repeat="option in vm.eesSettingIdOptions | filter:{ SettingID: '!' + vm.eesAdminSetupData.SettingID}

Solution 2

Modified your code, Please refer below changes.

ng-repeat="option in vm.eesSettingIdOptions | filter:{ SettingID:'!option.SettingID'}

Try using this way, it will work.

Share:
19,098
Roel
Author by

Roel

Updated on June 24, 2022

Comments

  • Roel
    Roel almost 2 years

    When I tried using the below syntax, it doesn't filter or doesn't exclude:-

    ng-repeat = "option in vm.eesSettingIdOptions | filter : { SettingID: '!vm.eesAdminSetupData.SettingID'}
    

    but it do works when I change it to:-

    ng-repeat = "option in vm.eesSettingIdOptions | filter : { SettingID: '!51'}
    

    they should be the same isn't it?

  • Roel
    Roel over 8 years
    I still have one issue. It's in a select options..when I tried to select..it doesn't shows anything but blank <option ng-repeat="option in vm.eesSettingIdOptions | filter:{ SettingID: '!'+ vm.eesAdminSetupData.SettingID} " value="{{option.SettingID}}">{{option.SettingID}} - {{option.Name}}</option>
  • Roel
    Roel over 8 years
    I tried that but it doesn't exclude option.SettingID in the option lists.
  • Chetan Sharma
    Chetan Sharma over 8 years
    you also cannot wright like 'vm.eesAdminSetupData.SettingID'. because while looping this don't know which value have to map.
  • Chetan Sharma
    Chetan Sharma over 8 years
    Just try moving out single quote from suggested code.
  • Roel
    Roel over 8 years
    Yes, I tried the suggested code. However, when I tried to select an option..it doesn't shows anything but blank <option ng-repeat="option in vm.eesSettingIdOptions | filter:{ SettingID: '!'+ vm.eesAdminSetupData.SettingID} " value="{{option.SettingID}}">{{option.SettingID}} - {{option.Name}}</option>
  • Roel
    Roel over 8 years
    when I tried to select an option..it doesn't shows anything but blank <option ng-repeat="option in vm.eesSettingIdOptions | filter:{ SettingID: '!'+ vm.eesAdminSetupData.SettingID} " value="{{option.SettingID}}">{{option.SettingID}} - {{option.Name}}</option>
  • tom redfern
    tom redfern over 8 years
    @Roel if this answer has solved your original problem then please accept it as the solution to your question. If you then need to ask another question, do not ask it in the comments, but create a new question instead. If you want z0r0 to look at your new question then you can leave him a comment under his answer and link to your new question. However, if you don't award the answer/upvote then he will probably not be inclined to help you next time.
  • z0r0
    z0r0 over 6 years