How to handle multiple dropdown filters on a page in Angular 6?How to use jQuery with Angular?How to detect a route change in Angular?Angular 2 - How to listen to event without a template?How can I close a dropdown on click outside?How to bundle an Angular app for productionAngular 2 router evaluating multiple route parametersAngular 2: can custom component handle its own events?Filtering Results of Observable Before Subscribing in Angular AppBuilding an API Call Holding Multiple Filter-selected Values in Angular AppModifying the CSS of ng2-completer

Permission on Database

Mimic lecturing on blackboard, facing audience

Circuit Analysis: Obtaining Close Loop OP - AMP Transfer function

Taxes on Dividends in a Roth IRA

Has the laser at Magurele, Romania reached a tenth of the Sun's power?

What features enable the Su-25 Frogfoot to operate with such a wide variety of fuels?

Is there a nicer/politer/more positive alternative for "negates"?

The IT department bottlenecks progress, how should I handle this?

How to explain what's wrong with this application of the chain rule?

How to draw a matrix with arrows in limited space

Pre-mixing cryogenic fuels and using only one fuel tank

Make a Bowl of Alphabet Soup

Review your own paper in Mathematics

What is the difference between lands and mana?

Which was the first story featuring espers?

What is the English pronunciation of "pain au chocolat"?

What kind of floor tile is this?

Why is so much work done on numerical verification of the Riemann Hypothesis?

Is it necessary to use pronouns with the verb "essere"?

Is my low blitz game drawing rate at www.chess.com an indicator that I am weak in chess?

Are Captain Marvel's powers affected by Thanos breaking the Tesseract and claiming the stone?

How to make money from a browser who sees 5 seconds into the future of any web page?

What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?

Does Doodling or Improvising on the Piano Have Any Benefits?



How to handle multiple dropdown filters on a page in Angular 6?


How to use jQuery with Angular?How to detect a route change in Angular?Angular 2 - How to listen to event without a template?How can I close a dropdown on click outside?How to bundle an Angular app for productionAngular 2 router evaluating multiple route parametersAngular 2: can custom component handle its own events?Filtering Results of Observable Before Subscribing in Angular AppBuilding an API Call Holding Multiple Filter-selected Values in Angular AppModifying the CSS of ng2-completer













0















So here is the scenario:



There are 4 dropdown filters(namely a,b,c,d)on a webpage.
In case the value received by the event triggered is "-1" or "undefined" , the complete data received from the API needs to be displayed while in other cases we need to match and display the matching entries.



The issue is that at any point there can any number of filters applied and for the same reason we have to handle every possible permutation. A normal approach is becoming really cumbersome and has lots of if else scenarios.



Is there is simpler approach to handling such case ?



Thanks.










share|improve this question






















  • what i understand from your question is that, you want to apply the options that are selected from dropdown as filters on data that is provided by API... Is that right?

    – Krishna
    Mar 7 at 5:22











  • @Krishna- Yes Sir and the data displayed should be matching the applied filter/s

    – Mukul_Vashistha
    Mar 7 at 5:26











  • Is it your own API or something from a 3rd party?

    – abney317
    Mar 7 at 5:32






  • 1





    Instead of calling api again you can store the full data in variable and apply pipe filter in angular and pass the selected values as params to the pipe and your logic to filter data goes in pipe

    – Krishna
    Mar 7 at 5:40











  • @abney317 - Our own API.

    – Mukul_Vashistha
    Mar 7 at 5:55















0















So here is the scenario:



There are 4 dropdown filters(namely a,b,c,d)on a webpage.
In case the value received by the event triggered is "-1" or "undefined" , the complete data received from the API needs to be displayed while in other cases we need to match and display the matching entries.



The issue is that at any point there can any number of filters applied and for the same reason we have to handle every possible permutation. A normal approach is becoming really cumbersome and has lots of if else scenarios.



Is there is simpler approach to handling such case ?



Thanks.










share|improve this question






















  • what i understand from your question is that, you want to apply the options that are selected from dropdown as filters on data that is provided by API... Is that right?

    – Krishna
    Mar 7 at 5:22











  • @Krishna- Yes Sir and the data displayed should be matching the applied filter/s

    – Mukul_Vashistha
    Mar 7 at 5:26











  • Is it your own API or something from a 3rd party?

    – abney317
    Mar 7 at 5:32






  • 1





    Instead of calling api again you can store the full data in variable and apply pipe filter in angular and pass the selected values as params to the pipe and your logic to filter data goes in pipe

    – Krishna
    Mar 7 at 5:40











  • @abney317 - Our own API.

    – Mukul_Vashistha
    Mar 7 at 5:55













0












0








0








So here is the scenario:



There are 4 dropdown filters(namely a,b,c,d)on a webpage.
In case the value received by the event triggered is "-1" or "undefined" , the complete data received from the API needs to be displayed while in other cases we need to match and display the matching entries.



The issue is that at any point there can any number of filters applied and for the same reason we have to handle every possible permutation. A normal approach is becoming really cumbersome and has lots of if else scenarios.



Is there is simpler approach to handling such case ?



Thanks.










share|improve this question














So here is the scenario:



There are 4 dropdown filters(namely a,b,c,d)on a webpage.
In case the value received by the event triggered is "-1" or "undefined" , the complete data received from the API needs to be displayed while in other cases we need to match and display the matching entries.



The issue is that at any point there can any number of filters applied and for the same reason we have to handle every possible permutation. A normal approach is becoming really cumbersome and has lots of if else scenarios.



Is there is simpler approach to handling such case ?



Thanks.







angular






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 7 at 5:02









Mukul_VashisthaMukul_Vashistha

2113




2113












  • what i understand from your question is that, you want to apply the options that are selected from dropdown as filters on data that is provided by API... Is that right?

    – Krishna
    Mar 7 at 5:22











  • @Krishna- Yes Sir and the data displayed should be matching the applied filter/s

    – Mukul_Vashistha
    Mar 7 at 5:26











  • Is it your own API or something from a 3rd party?

    – abney317
    Mar 7 at 5:32






  • 1





    Instead of calling api again you can store the full data in variable and apply pipe filter in angular and pass the selected values as params to the pipe and your logic to filter data goes in pipe

    – Krishna
    Mar 7 at 5:40











  • @abney317 - Our own API.

    – Mukul_Vashistha
    Mar 7 at 5:55

















  • what i understand from your question is that, you want to apply the options that are selected from dropdown as filters on data that is provided by API... Is that right?

    – Krishna
    Mar 7 at 5:22











  • @Krishna- Yes Sir and the data displayed should be matching the applied filter/s

    – Mukul_Vashistha
    Mar 7 at 5:26











  • Is it your own API or something from a 3rd party?

    – abney317
    Mar 7 at 5:32






  • 1





    Instead of calling api again you can store the full data in variable and apply pipe filter in angular and pass the selected values as params to the pipe and your logic to filter data goes in pipe

    – Krishna
    Mar 7 at 5:40











  • @abney317 - Our own API.

    – Mukul_Vashistha
    Mar 7 at 5:55
















what i understand from your question is that, you want to apply the options that are selected from dropdown as filters on data that is provided by API... Is that right?

– Krishna
Mar 7 at 5:22





what i understand from your question is that, you want to apply the options that are selected from dropdown as filters on data that is provided by API... Is that right?

– Krishna
Mar 7 at 5:22













@Krishna- Yes Sir and the data displayed should be matching the applied filter/s

– Mukul_Vashistha
Mar 7 at 5:26





@Krishna- Yes Sir and the data displayed should be matching the applied filter/s

– Mukul_Vashistha
Mar 7 at 5:26













Is it your own API or something from a 3rd party?

– abney317
Mar 7 at 5:32





Is it your own API or something from a 3rd party?

– abney317
Mar 7 at 5:32




1




1





Instead of calling api again you can store the full data in variable and apply pipe filter in angular and pass the selected values as params to the pipe and your logic to filter data goes in pipe

– Krishna
Mar 7 at 5:40





Instead of calling api again you can store the full data in variable and apply pipe filter in angular and pass the selected values as params to the pipe and your logic to filter data goes in pipe

– Krishna
Mar 7 at 5:40













@abney317 - Our own API.

– Mukul_Vashistha
Mar 7 at 5:55





@abney317 - Our own API.

– Mukul_Vashistha
Mar 7 at 5:55












1 Answer
1






active

oldest

votes


















0














First check all of them to see if they are -1



if a==-1 or b==-1 or c==-1 or d==-1
retrieve all
else
retrieve based on values


this way you sure that in the else block non of them is null or -1,hope it helps






share|improve this answer























  • Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.

    – Mukul_Vashistha
    Mar 7 at 9:09











  • Have you consider pushing all filters in array and send it to server?

    – ehsan kiani
    Mar 7 at 15:30










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036412%2fhow-to-handle-multiple-dropdown-filters-on-a-page-in-angular-6%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














First check all of them to see if they are -1



if a==-1 or b==-1 or c==-1 or d==-1
retrieve all
else
retrieve based on values


this way you sure that in the else block non of them is null or -1,hope it helps






share|improve this answer























  • Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.

    – Mukul_Vashistha
    Mar 7 at 9:09











  • Have you consider pushing all filters in array and send it to server?

    – ehsan kiani
    Mar 7 at 15:30















0














First check all of them to see if they are -1



if a==-1 or b==-1 or c==-1 or d==-1
retrieve all
else
retrieve based on values


this way you sure that in the else block non of them is null or -1,hope it helps






share|improve this answer























  • Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.

    – Mukul_Vashistha
    Mar 7 at 9:09











  • Have you consider pushing all filters in array and send it to server?

    – ehsan kiani
    Mar 7 at 15:30













0












0








0







First check all of them to see if they are -1



if a==-1 or b==-1 or c==-1 or d==-1
retrieve all
else
retrieve based on values


this way you sure that in the else block non of them is null or -1,hope it helps






share|improve this answer













First check all of them to see if they are -1



if a==-1 or b==-1 or c==-1 or d==-1
retrieve all
else
retrieve based on values


this way you sure that in the else block non of them is null or -1,hope it helps







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 7 at 6:10









ehsan kianiehsan kiani

1128




1128












  • Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.

    – Mukul_Vashistha
    Mar 7 at 9:09











  • Have you consider pushing all filters in array and send it to server?

    – ehsan kiani
    Mar 7 at 15:30

















  • Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.

    – Mukul_Vashistha
    Mar 7 at 9:09











  • Have you consider pushing all filters in array and send it to server?

    – ehsan kiani
    Mar 7 at 15:30
















Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.

– Mukul_Vashistha
Mar 7 at 9:09





Well this wouldn't serve the purpose since the else part would still need a lot of ifs to handle all the permutations since we do not know how many filters will be applied at any point.

– Mukul_Vashistha
Mar 7 at 9:09













Have you consider pushing all filters in array and send it to server?

– ehsan kiani
Mar 7 at 15:30





Have you consider pushing all filters in array and send it to server?

– ehsan kiani
Mar 7 at 15:30



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036412%2fhow-to-handle-multiple-dropdown-filters-on-a-page-in-angular-6%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved