Ask a question: Ng-init initialization, I initialize a question title and description, but the title and description may appear in single quotation marks and double quotes, the results will be due to parse the problem error. That's it.
' >
This is the end of the situation. Do you have any solutions? (tried some of the escape character functions of PHP, it seems to be invalid)
Reply content:
Ask a question: Ng-init initialization, I initialize a question title and description, but the title and description may appear in single quotation marks and double quotes, the results will be due to parse the problem error. That's it.
' >
This is the end of the situation. Do you have any solutions? (tried some of the escape character functions of PHP, it seems to be invalid)
I'm not sure about the problem, but I tried it, but I can write it.
1, with Ng-init is not the first time to see, but I think that the way to define the variable is not good, if the page is very long, do you want to look at the HTML line to find the variable you define?
2, in JS is allowed to double quotes in single quotes, if you put this variable in the variable (implemented in controller) can be easily implemented
Example:$scope.text = 'http:/localhost:"3000"/posts.json';
3, Angularjs in the ng-init is defined in the variable is not allowed to have escape characters and single double quotation marks, temporarily did not think of the method, I try Again
Add: I do not understand the PHP involved, it seems that many people use Ng-init
Http://www.codesec.net/view/167161.html
I talked about the escape character.
Print this kind of JSON directly in HTML note that the quotation marks and HTML special symbols are hex-coded, and Json_encode in PHP can pass in the second parameter, which sets the encoding of special characters:
Json_hex_tag: Encode < and > symbols as \u003c and \u003e//json_hex_apos: Convert single quotes to \u0027//json_hex_quot: Convert double quotes to \u0022// ...
Http://blog.csdn.net/wusuopubupt/article ...
Http://php.net/htmlspecialchars
You can also use app.value(key, value)
andapp.constant(key, value)
http://stackoverflow.com/questions/14523 ...
Http://hellobug.github.io/blog/angularjs ...