I got this:
{{columns.field}} and this {{resultado.!!!}}
and inside the !!! I need to put the {{columns.field}} I can't find a way to do it
I need to do it like this because I don't know the field in !!!, for that reason I got the {{columns.field}}, in this expression I picked up the value I need to put in !!!.
I'm sorry for my bad way of expressing myself
I tried something like this
Ready for top level Javascript ?
{{resultado[columns.field]}}
Related
I have an HTML array with data like so:
data-groups='["category_all", "data goes here"]'
I have a prop called "title" which contains the string I need to render in the "data goes here" area. I've tried using v-bind, but then I lose the array which I need to have in order for the original sort feature to work.
I google'd a few different ways to either escape or render quotes, and most refer to v-bind which again, won't work in this instance.
Any help would be appreciated :)
I was using Shuffle.js and for anyone else seeking an answer, it was in the documentation:
https://vestride.github.io/Shuffle/docs/getting-started
Alternatively, you can set the delimiter option to a comma (delimiter: ',') and the data-groups attribute will be split on that character.
Then changing the above line of code to:
:data-groups="item.category.title + ',all'"
works just fine :)
I have used Safe Navigation Operator for Objects to load on Asynchronous calls and it is pretty amazing. I thought I could reproduce the same for Arrays but it displays a template parse error in my Angular code. I know *ngIf is an alternative solution, but is there a more simpler(by code) way just like the Safe Navigation Operator?
<div class="mock">
<h5>{{data?.title}}</h5> //This works
<h6>{{data?.body}}</h6> //This works
<h6>{{simpleData?[0]}}</h6> // This is what I tried to implement
</div>
Is there something like a Safe Navigation Operator that can be used on Arrays?
Yes, what you are looking for is known as the Optional Chaining operator (JavaScript / TypeScript).
The syntax shown in the MDN JavaScript documentation is:
obj.val?.prop
obj.val?.[expr]
obj.arr?.[index]
obj.func?.(args)
So, to achieve what you want, you need to change your example from:
<h6>{{simpleData?[0]}}</h6>
To:
<h6>{{simpleData?.[0]}}</h6>
^
Also see How to use optional chaining with array in Typescript?.
is there a more simpler(by code) way just like the Safe Navigation Operator?
There is ternary operator.
condition ? expr1 : expr2
<h6>{{simpleData?simpleData[0]:''}}</h6>
Of cause it's a matter of taste, but in such cases I tend to use a shorter approach:
<h6>{{(simpleData || [])[0]}}</h6>
The other answers amount to the same thing, but I find foo && foo[0] to be the most readable. The right side of the logical-and operator won't be evaluated if the left side is falsy, so you safely get undefined (or I guess null, if you don't believe Douglas Crockford.) with minimal extra characters.
For that matter, you asked for a "simpler" solution, but actually *ngIf is probably correct for the use case you gave. If you use any of the answers here, you'll wind up with an empty h6 tag that you didn't need. If you make the tag itself conditional, you can just put foo[0] in the handlebars and be confident that it won't be evaluated when foo is still undefined, plus you never pollute the page with an empty tag.
I am trying to find all <br> instances in the following string, but only in the "categories" class:
<td>bla<br>bla</td><td class="categories">cat1<br>cat2<br>cat3</td>
I am realy new to regex, and this is what I tried so far, but it only finds the first <br> after cat1 and takes the whole part in front of it in the result as well...
(?>categories">).*?<br>
EDIT: I want to find all <br> occurences to replace them with a comma. For the moment I'm using a text editor (Sublime Text) to achieve this...
Why would you want to use regex? What are you trying to validate?
http://en.wikipedia.org/wiki/Regular_expression
If you want to find html elements using class variables then you want to look into javascript or jquery
http://api.jquery.com/class-selector/
Hope that helps a bit
I know this has been asked at least a thousand times but I can't find a proper regex that will match a name in this string here:
<td><div id="topbarUserName">Donald</div></td>
I want to get the name 'Donald' and the regex that's the closest is >[a-zA-Z0-9]+ but the result is >Donald.
I'm coding in PureBasic (It's syntax is similar to that of Basic) and it uses the PCRE library for regular expressions.
Can anyone help?
Josh's pattern will work if you only make use of the numbered group, not the whole match. If you have to use the whole match, use something like (?<=>)(\w+?)(?=<)
Either way, regex is widely known to not be good for parsing HTML.
Explanation:
(?<=) is used to check if something appears before the current item.
\w+? will match any "word"-character, one or more times, but stop whenever the rest of the pattern matches something, for this situation the ? could have been left out.
(?=) is used to check if something appears after the current item.
Try this
It should capture anything that is a letter / number
>([\w]+)<
Also I'm not exactly sure what your project limitations are, but it would be much easier to do something like this
$('#topbarUserName').text();
in jQuery instead of using a regex.
>([a-zA-Z]+) should do the Trick. Remember to get the grouping right.
Why not doing it with plain old basic string-functions?
a.w = FindString(HTMLstring.s, "topbarUserName") + 16 ; 2 for "> and topbar...
If a > 0
b.w = FindString(HTMLstring, "<", a)
If b > 0
c.w = b - a
Donald.s = Mid(HTMLstring,a, c)
EndIf
EndIf
Debug Donald
I need to assign a variable which will be used to create the id label for some html elements.
And it needs to be unique.
I tried
{assign var=unique_id value=`10|mt_rand:20`}
and
{math equation='rand(10,100)'}
But I don't know how to use the result
I don't have any other ideas
this is how you set and use a random value but that deoesn't mean it will be unique.
{assign var=unique_id value=10|mt_rand:20}
{$unique_id}
can you describe a bigger picture of what your doing ?
I wrote an little Smarty plugin some years ago: https://www.markus.zierhut.name/2010/05/21/php-mit-smarty-zufallszahl-erzeugen/
It's a bit easier to use than handling with mt_rand inside the assign-function. And it keeps compatible with the split of Model and View.