Formatting values with AngularJs filters - angularjs

I am writing a common control that will be used to format data inside a grid. It has 2 parameters that user can set:
filter (string) that is used to format value
parameters (any[]) that are used by the filter
In the code I am going to call $filter(filter)(value, ...) - here is my problem. How do I pass my parameters? Each filter can have from no parameters to who knows how many. So, is there a nice way to pass variable number of parameters in Angular? So far I did not run into a way of doing it.

You should be able to do:
$filter(filter).apply(this, parameters)

Related

Is it possible to pass a dynamic group value to tokenizer in camel?

I want to specify the grouping size dynamically.
Is something like this possible ?
split().tokenize("\n", ..value from header or property...)
how to specify this value ?
--Clarifying: my question reads like I intend to dynamically change it during the execution of the route.
This is not what I need,
I need just a way to pass in a configurable splitsize, that is calculated in a bean.
No that is not possible, the group is a fixed number.
However instead of using tokenize you can use a java method call and return an Expression where you can do something similar to what TokenizeLanguage#createExpression does but where you can set the group value with a dynamic value.

API Gateway pass array of parameters in querystring

I have some issues with passing array of parameters to query string for GET method, for example, /resource&item=1&item=2&item=3.
I have tried to pass parameters separated by commas and by &, it doesn`t work. How to configure API Gateway to do this? Can anyone help me?
Your example was using an ampersand (&) instead of a question mark (?) for separating the query string parameter from the path. I'm assuming that's just a typo.
Try passing the array using json syntax like
/resource?item=['1','2','3']
have you tried this way :
/resource&item[]=1&item[]=2&item[]=3
The way you used would erase the first data by the last data in the url.
What we are doing in our company is to pass data separated by ,. On Backend we explode the parameter and make it array again. I am not sure if there is more better way to do it or not. Let me know if you find any.
like ?items=1,2,3,4
And we get explode items with , through extra code
and get result as [1,2,3,4]

String concatination in angular filter with scope variables

After combining value of two scope variable I wants to apply filter on the resultant output.
Let me explain more clearly where I am stuck.
<h2>{{scope_variable1 | filter_name}}<H2>
Here in my above html I have scope_variable1 in scope which contains string value.This is working fine but I wants to combine value of two scope variables and then i wants to apply filter.
I have one more scope_variable2 and which also contains string value now I want to concatenate both variable's value and then want to apply filter.
Is it possible to do on html element?
As I am aware of other ways to achieve like by using controller and taking third variable in scope but i want to know if it directly possible.

Format for passing a numerically indexed array in a get request

I know that the standard method for passing named parameters in a get request, is:
?paramName=value&anotherParam=anotherValue...
In my case, I want to pass an array of parameters
However, I want to pass multiple parameters with the same meaning - an array.
In js that would be
var users = ['bob', 'sam', 'bill'];
and I want to pass the users array via get.
What would be the way to accomplish this?
You will need to serialize them into some form of string that can be re-parsed into an array.
For, example, you could use...
?param[]=a&param[]=b&param[]=c
...or something like...
?params=[a][b][b].

Pass array as parameter to JAX-RS resource

I have many parameters to pass to the server using JAX-RS.
Is there a way to pass or AarryList with the URL?
You have a few options here.
Option 1: A query parameter with multiple values
You can supply multiple simple values for a single query parameter. For example, your query string might look like:
PUT /path/to/my/resource?param1=value1&param1=value2&param1=value3
Here the request parameter param1 has three values, and the container will give you access to all three values as an array (See Query string structure).
Option 2: Supply complex data in the PUT body
If you need to submit complex data in a PUT request, this is typically done by supplying that content in the request body. Of course, this payload can be xml (and bound via JAXB).
Remember the point of the URI is to identify a resource (RFC 3986, 3.4), and if this array of values is data that is needed to identify a resource then the URI is a good place for this. If on the other hand this array of data forms part of the new representation that is being submitted in this PUT request, then it belongs in the request body.
Having said that, unless you really do just need an array of simple values, I'd recommend choosing the Option 2. I can't think of a good reason to use URL-encoded XML in the URL, but I'd be interested to hear more about exactly what this data is.
We can get the Query parameters and corresponding values as a Map,
#GET
#Produces(MediaType.APPLICATION_JSON)
public void test(#Context UriInfo ui) {
MultivaluedMap<String, String> map = ui.getQueryParameters();
String name = map.getFirst("name");
String age = map.getFirst("age");
System.out.println(name);
System.out.println(age);
}

Resources