AngularJS ng-csp Instruction
AngularJS Examples
Modify the behavior of "eval" and inline styles in AngularJS:
<
body
ng-app=
""
ng-csp...
Try it »
Definition and Usage
ng-csp The directive is used to modify the security policy of AngularJS.
If a ng-csp directive, AngularJS will not execute the eval function, so inline styles cannot be injected.
Settings ng-csp The directive is no-unsafe-eval, which prevents AngularJS from executing the eval function but allows injecting inline styles.
Settings ng-csp The directive is ** no-inline-style**, which prevents AngularJS from injecting inline styles but allows executing the eval function.
If developing Google Chrome extensions or Windows apps ng-csp the directive is required.
**Note:**ng-csp The directive does not affect JavaScript, but it modifies the way AngularJS works. This means: you can still write eval functions and they will execute normally, but AngularJS cannot execute its own eval functions. Using compatibility mode reduces performance by 30%.
Syntax
<
element
ng-csp="no-unsafe-eval | no-inline-style"
<
/element
Parameter value
| Value | Description |
|---|---|
| no-unsafe-eval | |
| no-inline-style | The value can be set to empty, meaning neither eval nor inline styles are allowed. |
可以设置其中一个值。
你也可以同时设置两个值使用分号隔开,但这与留空的效果是一样的。 |
AngularJS Reference Manual