Can i use or logic in ng-when - angularjs

I would like to do something like this:
<ANY ng-switch-when="matchValue1 || matchValue2">...</ANY>
To simplify my expression, currently I do that same thing for matchValue1 and matchValue2.

According to angular web site "Be aware that the attribute values to match against cannot be expressions. They are interpreted as literal string values to match against. For example, ng-switch-when="someVal" will match against the string "someVal" not against the value of the expression $scope.someVal."
Using ng-show would be useful in your case.

Related

regex with OR condition not working in angularjs [duplicate]

I'm creating a javascript regex to match queries in a search engine string. I am having a problem with alternation. I have the following regex:
.*baidu.com.*[/?].*wd{1}=
I want to be able to match strings that have the string 'word' or 'qw' in addition to 'wd', but everything I try is unsuccessful. I thought I would be able to do something like the following:
.*baidu.com.*[/?].*[wd|word|qw]{1}=
but it does not seem to work.
replace [wd|word|qw] with (wd|word|qw) or (?:wd|word|qw).
[] denotes character sets, () denotes logical groupings.
Your expression:
.*baidu.com.*[/?].*[wd|word|qw]{1}=
does need a few changes, including [wd|word|qw] to (wd|word|qw) and getting rid of the redundant {1}, like so:
.*baidu.com.*[/?].*(wd|word|qw)=
But you also need to understand that the first part of your expression (.*baidu.com.*[/?].*) will match baidu.com hello what spelling/handle????????? or hbaidu-com/ or even something like lkas----jhdf lkja$##!3hdsfbaidugcomlaksjhdf.[($?lakshf, because the dot (.) matches any character except newlines... to match a literal dot, you have to escape it with a backslash (like \.)
There are several approaches you could take to match things in a URL, but we could help you more if you tell us what you are trying to do or accomplish - perhaps regex is not the best solution or (EDIT) only part of the best solution?

Apply conditional formatting depending on an other field's value

On the field DaysSinceRequest of an an Access' Form, I am applying a conditional formatting depending on its value in eavch record, that part is fine.
But how could I tell "Apply the conditional formatting to the field DaysSinceRequest ONLY if the field DatePartReceived is empty/null" ?
Is there a way to do this ?
PS : Just to show that I've done something before haters start down rating, here are the rules I've applied to the field DaysSinceRequest and the result in the Datasheet View
Tell if if my post is not clear enough, thanks
Just use Expression Is instead of Field Value Is and in Expression field you can use any expression, which evaluates to Boolean value. In your case you can use IsNull function

Is there a way to add operators to AngularJS expression?

I would like to add beginsWith (^=) and endsWith ($=).
E.g., scope.$eval('"abcd" ^= "a"') should return 'true'
According to Angular's documentation on expressions, you should use controller\filter:
No function declarations or RegExp creation with literal notation
You can't declare functions or create regular expressions from within
AngularJS expressions. This is to avoid complex model transformation
logic inside templates. Such logic is better placed in a controller or
in a dedicated filter where it can be tested properly.

Difference between "reverse" and "-property" with orderBy in ngRepeat?

In the AngularJS doc for "orderBy", the description of the "string" property is as follows (with my emphasis):
An Angular expression which evaluates to an object to order by, such as 'name' to sort by a property called 'name'. Optionally prefixed with + or - to control ascending or descending sort order (for example, +name or -name).
The description of the "reverse" property is as follows:
Reverse the order the array.
So what should be the difference between using "-property" and "reverse"? Should both of these do the same thing?
For my test case, I can't get "reverse" to do anything. I constructed a plunkr with three ngRepeats. The first one is without any ordering, the second one ordered with "reverse", and the last ordered with "-property". The latter does what I expect, the former doesn't appear to do anything.
The documentation is clearly ambiguous, but I would have expected "reverse" and "-property" to do the same thing. What's going on here?
Looking at the manual you'll find reverse to be of type boolean. Which indicates that it's value will be looked up in the current scope or is meant to be literal. Simply plucking in reverse will then evaluate to undefined (because it's probably not defined on the scope) which is falsy and thus reverse has no effect. Use a scope value or a litteral (true, false) to see it's effect.
The reason to have two ways of reversing the sort order is because it's hard to to change the +/- through data-binding techniques, while it's easy to simply refer to a scope variable using the reverse expression. And thus change the order through data-binding (e.g. button clicks which change a scope variable, which is actually an example on the manual page).
Instead of orderBy:'lastRun':reverse put quotes around 'reverse': orderBy:'lastRun':'reverse'

Why only one equality sign for the ancestor (Google Datastore)

UserModel.query (self.login == login, self.name == name, ancestor = ancestor_key)
This is a Python statement to retrieve data from the GAE datastore. Can you explain why I use one equality sign (=) for the ancestor, and two signs (==) for other properties?
When I use two equality signs, a statement like self.login == login should return a boolean value, that is then passed to the function. But it doesn't work this way, right?
For the second part of your question:
python lets you overload 'equals' (and less-than and greather-than and so on) for a class (and you can have it return anything, not just true/false), and ndb has done just that for Properties to return query FilterNodes. Check the source: https://code.google.com/p/appengine-ndb-experiment/source/browse/ndb/model.py#858
You are mixing up a comparison with an assignment.
See the docs https://developers.google.com/appengine/docs/python/ndb/queries#filter_by_prop
The factory for creating a query object for this Kind takes an ancestor argument which defines the scope of the query for the given ancestor. It also accepts a number of expressions that defines filters. The use of self.login == login is an expression defining a filter.
I don't understand the last part of your question.
Another way of defining the query would be
UserModel.query(ancestor=ancestor_key).filter(self.login==login)
The ability to supply filters in query() is just a short cut for this form.

Resources