Ask Angularjs in the ng-init there is a single double quotation mark causes the problem of parsing error

Source: Internet
Author: User
Keywords angularjs php
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.