Ask a question: ng-init initialization. I initialize the title and description of a question. However, single quotation marks and double quotation marks may appear in the title and description, and an error will be reported at the end of the result. Yes & amp; lt ;? Php $ question_title & quot; & #039; aaaa & #039; bbb & #039; & quot ;? & Amp; gt; & amp; lt; divng-ini... ask a question: ng-init initialization. I initialize the title and description of a question. However, single quotation marks and double quotation marks may appear in the title and description, and an error will be reported at the end of the result. Yes
This is the case. Is there any solution? (It seems that some escape character functions in php are invalid)
Reply content:
Ask a question: ng-init initialization. I initialize the title and description of a question. However, single quotation marks and double quotation marks may appear in the title and description, and an error will be reported at the end of the result. Yes
This is the case. Is there any solution? (It seems that some escape character functions in php are invalid)
I am not quite clear about this problem, but I have tried it and can still write it out.
1. using ng-init is not the first time I have seen it, but I don't think it is a good way to define variables. if the page is very long, do you have to look at the html line to find the variable you defined?
2. double quotation marks are allowed in JavaScript. this variable can be easily implemented if you save it in a variable (implemented in controller ).
Example:$scope.text = 'http:/localhost:"3000"/posts.json';
3. the variables defined by angularjs in ng-init do not allow escape characters and single double quotation marks. I did not expect the method for the moment. I will try again.
I don't know much about php. it seems that many people use ng-init.
Http://www.codesec.net/view/167161.html
Escape characters
To print this type of JSON directly in HTML, note that the quotation marks and special characters in HTML are both HEX encoded. the json_encode in PHP can be passed into the second parameter to set the encoding method for special characters:
// JSON_HEX_TAG: ENCODE <and> and other 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 useapp.value(key, value)Andapp.constant(key, value)
Http://stackoverflow.com/questions/14523...
Http://hellobug.github.io/blog/angularjs...