Let's say we are passing data from apache velocity to angularjs and the data is some string that contain quotes,
the error on screen:
Error: [$parse:lexerr] http://errors.angularjs.org/1.2.22/$parse/lexerr?
p0=Unterminated%20quote&p1=s%20327-
my code :
<span ng-init='draftDemands=$draftDemands;'>
how to solve this problem
When i use $esc.xml($draftDemands), it work my last example,
Are you escaping characters in Velocit's generated code? https://velocity.apache.org/tools/2.0/apidocs/org/apache/velocity/tools/generic/EscapeTool.html
Check also how angular does escaping via: Strict Contextual Escaping. So there is no need to render characters as HTML explicitly.
This discussion could put some more light on the case.
This should also work: how to pass special characters into ng-init in angularjs from python
Related
I am running a HTTP call to bring back data in JSON format but this is bringing through an extra set of square brackets that is causing issues when i am trying to recognise the array. See screen shots.
I can remove the extra set manually in a JSON editor but need to try and find a way of doing this automatically as part of my call.
I am running the call through Integromat and have looked at using Regex but couldn't find the correct code combinations.
Any help or advise much appreciated.
You can use the replace function and insert the brackets that need to be found using regex pattern making sure you denote the bracket at the starting position and the bracket at the end of the string to be replaced with emptystring
Don't check "Parse Response" in HTTP Request module.
That way Data will be returned as long text
Use "Text Parser"'s "Replace", look for ^[|]$ and replace it with emptystring. Make sure you check "Global Match", otherwise it will only do to the first match only=[
3.Then just Parse Json from parsed(replaced) text
I think this article will help.
https://medium.com/#petr.hnilica/json-in-integromat-how-to-create-an-array-from-collections-with-the-same-structure-2991b985e03e
I am trying to write an expression for AngularJs. I need to use it inside an ng-pattern directive so to put a validation constraint to a form.
What I actually need is a regex for a URL in https that has always to end with a slash: /.
It would be nice if it ends more specifically in /pre/last/
How do I solve this problem?
This RegEx might help us to match /pre/last/. It creates two groups, in case we wish to call those groups, we can do so using $2 for /pre/last/ and $1 for first the part of our URL (Please see the image).
'/(.+)(\/pre\/last\/)/g'
We might not want to bound it with start (^) or end ($) anchors, and it might still does our desired matchings.
This post explains how we would do so in JavaScript.
Maybe this help
/.*\/pre\/last\/$/g
what it basically match is any string that ends with /pre/last/
I'm using angularJS translateProvider and in the resource file i have a prefix "paragraph \u003cbr /\u003e paragraph" witch gives me. paragraph <br /> paragraph.
but what i need is a break-line (or new line) like so
paragraph
paragraph
I would appreciate the help thank.
I'm not sure that is really possible to pass unicode symbols in angular-translate. Almost same questions was in issues to that package on github: https://github.com/angular-translate/angular-translate/issues/554, https://github.com/angular-translate/angular-translate/issues/595, and answer was just to use <br> tag in translation string.
But i think, may be you can write some variable or placeholder in translation strings, and after translation in Controller / Directive, you can replace it with str.replace('SOMEPLACEHOLDER', '\n')?
You should update the Sanitize Value Strategy of the $translateProvider.
In the config phase set
$translateProvider.useSanitizeValueStrategy('escaped');
Also you should include ngSanitize as a dependency and also angular-sanitize.js.
I am using w3c validator with html5. I have an array afilter[]=abc I am passing in the href and I have tried escaping the brackets as follows:
<a href='slideshowform.php?x=y&afilter[]=abc'>phases of matter</a>
But I am still getting the error:
Bad value slideshowform.php?x=y&afilter[]=abc for attribute href on element a: Illegal character in query component.
How can I pass an array without getting errors - or did I escape the brackets incorrectly?
You have to URL encode it, not HTML encode it. Your URL would have to look like the following:
slideshowform.php?x=y&afilter%5B%5D=abc
Most programming languages have stuff like this built in (e.g. rawurlencode() in PHP or encodeURI in JavaScript) or you can simply use an online service like (no affiliation, just one of the first search results) http://www.url-encode-decode.com/
Of course it’s a good idea to encode the HTML reserved characters for outputting the link in an HTML document as well. So you’d end up with the following URL within your HTML document.
slideshowform.php?x=y&afilter%5B%5D=abc
I have a forum like site, where people should be able to add strings like:
<<<<<
>.<
etc.
Also I want to preserve the new lines. Besides I replace many newlines in the server with 1.
For first feature I found the solution is to use ng-bind-html="myText"
that works.
But I have a problem with the newlines, not matter what I do, they are not displayed.
If I don't do anything (also no replacements in the server), they are rendered as newlines in the source and not displayed.
If I replace them with <br> or <br/> before rendering, they show as source -> <br> or <br/>.
If I don't use ng-bind-html anymore, and render the text as normal expression, I get escaped html: <br> (besides, in this case, the strings mentioned first also don't work).
What do I have to do? Thanks in advance!
It's more of a CSS issue. Use: white-space: pre;.