0

I want to create a dynamic query (Select * from <table name> where ..) using angular js, html, javascript. The drop-down should come for the conditions ('and' , 'or', etc) e.g. -> select <dropdown> from <dropdown> where <dropdown> . I am new to it. So please explain in proper example.

5
  • 2
    Please share what have you tried so far. Commented Jun 22, 2016 at 6:11
  • A simple example would be make an ajax call to your controller to get data from the database and then bind the data to your drop down. Commented Jun 22, 2016 at 6:13
  • Can u please show an example? Commented Jun 22, 2016 at 6:14
  • Here see an example from question already asked in SO - stackoverflow.com/questions/15688313/… Commented Jun 22, 2016 at 6:15
  • I think you should at least try to start to implement something before you ask for help on SO, and if you have, please share it with us. Commented Jun 22, 2016 at 6:28

1 Answer 1

0
$.ajax({
    type: 'POST',
    url: 'DropDownController',
    dataType: 'json',
    success: function(result) {
        $.each(result, function() {
            $("#drpDown").append(
                $('<option/>', {
                    value: this,
                    html: this
                })
            );
        });
    }
});

What happens at the endpoint is some controllerDropDownController may be if you are using Spring MVC it would be something like /DropDownController where you can write you query to call database using orm or whatever you use and returned is json which binds to the dropdown with id="drpDown"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.