Is it possible to append a static subfield to a dynamic ng-model identifier?
ng-model="newDevice[field.name].min"
ng-model="newDevice[field.name].max"
I need the "min" and the "max" as static fields. But the example did'nt work.
thanks!
Seems to work for me. You can take a look at this plunker and see the difference from your example:
http://plnkr.co/edit/0a2TFf7GtAz8VN0JTUin?p=preview
Or you can provide a plunker of your own that shows your problem.
Update: In order to use newDevice[field.name].min, you must have an object on your scope called new device, and one of its properties must be the value of field.name. Otherwise you can't use ng-model as is.
Related
I am having different objects like in the code sample below. I have some checkboxes that filters based on brewer, style, aroma and country. It is filtering only if it has one property in the array.
What is the best solution to make the filter work based on all the elements in the array? I checked some other questions and I couldn't find anything related.
It will be great if any of you could help me.
Thanks.
sample of the code here: http://pastie.org/10787362
You could use filter method of Javascript Array() object.
For example:
$scope.filteredNames = $scope.names.filter(function(element) {
return
'brewer1' in element.brewers &&
'aroma1' in element.aromas
;
});
$scope.filteredNames should contain all names with 'brewer1' value in brewers property AND 'aroma1' value in aromas property...
I don't want to use any Javascript code or $scope variable.
Just want to print 1,2,3,4,5 values in Drop Down using ng-options.
This is what I have tried:
<select ng-name="priority" ng-options="priority for priority in Range(1, 5)"></select>
Working solution, within your requirements:
<select ng-model="priority" ng-options="priority for priority in [1,2,3,4,5]"></select>
Just in case, here's the plnkr to experiment with. If you have a quick look at the angular source code, you will see that ng-options requires select element as well as ng-model. Not sure what is the Range implementation mentioned in your example, but here is a very creative thread on this topic. Though, if your array is always the same and you really don't want to use scope (but why?), you're better off with the solution above.
How do you get the id for the underlying record in a combobox with dojo? I've tried altering the following sample but all I can get is the text shown to the user (the "name" property of each array element), and NOT the state's two-letter abbreviation ("id" property).
http://dojotoolkit.org/reference-guide/1.10/dijit/form/ComboBox.html#id3
thanks. PS, I'm a total noob with dojo. This is my first experiment with it.
It's like #CodeCrisis said, you can get the item by using dijit.byId('stateSelect').item. Though I'm not really pleased with how outdated the docs are (the dijit.byId()command is deprecated), this is a proper 1.10 solution:
query("button").on('click', function() {
console.log(comboBox.get('item'));
});
This will return the selected record in the store (containing both the id and name properties in this case).
A full, working example can be found here: http://jsfiddle.net/zt6xggL8/
How about this...
base on the link given
http://dojotoolkit.org/reference-guide/1.10/dijit/form/ComboBox.html#id3
change this onclick function
onClick="alert(dijit.byId('stateSelect').get('value'))"
into
onClick="alert(dijit.byId('stateSelect').item.id)"
i know this is not the best answer but i hope this will help you..
check out the answer of Philippe
Dojo : ComboBox selected and show data id
hehehe... :)
just passing by...
Not the prettiest but this works. Basically need to query the 'store' variable for the name that is being displayed when you just use 'value'. [0] denotes the first object in the store list, so if you have multiples with the same name, you'll need to use the foreach() function.
<button onClick="var namevar=dijit.byId('stateSelect').get('value');
alert(dijit.byId('stateSelect').get('store').query({name:namevar})[0].id);">
Get value
</button>
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.
For instance, is it possible to define:
#FindBy(By.id("id1") OR By.id("form1:id1"))
public WebElement button
So that button having either "id1" or "form1:id1" should work fine?
You can use the #FindBys annotation, the syntax is:
#FindBys({#FindBy(id = "foo"),
#FindBy(className = "bar")})
The JavaDoc describes it here:
http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/support/FindBys.html
Well,
use whathever you want, as long as it works
Personally I would use #FindBy(By.id("id1")) but it is just point of choice.
Also, there is no value added in referring same element twice with two different methods. It will only cause mess in your code
EDIT
As I understood your comment, there is element on the page which constantly changes its ID. If you need to refer to such elements, try using xPath See for example this xpath tutorial
The idea is that you will point to some place in the DOM rather than to specific ID
Use Xpath or CSS selector to do that. Or Java to store the ID name in String and then you can fill it to your Id.