Easy Tutorial
❮ Angularjs Html Events Ng Ng Style ❯

AngularJS ng-csp Directive

AngularJS Reference Manual


AngularJS Example

Modify the behavior of "eval" and inline styles in AngularJS:


Definition and Usage

The ng-csp directive is used to modify the security policy of AngularJS.

If the ng-csp directive is used, AngularJS will not execute the eval function, preventing the injection of inline styles.

Setting the ng-csp directive to no-unsafe-eval will prevent AngularJS from executing the eval function but allow the injection of inline styles.

Setting the ng-csp directive to no-inline-style will prevent AngularJS from injecting inline styles but allow the execution of the eval function.

The ng-csp directive is mandatory for developing Google Chrome extensions or Windows applications.

Note: The ng-csp directive does not affect JavaScript but modifies the way AngularJS operates, meaning: you can still write and execute eval functions, but AngularJS cannot execute its own eval function. Using compatibility mode can reduce performance by 30%.


Syntax


Parameter Values

Value Description
no-unsafe-eval <br>no-inline-style The value can be set to empty, meaning neither eval nor inline styles are allowed. <br>You can set one of the values. <br>You can also set both values separated by a semicolon, but this has the same effect as leaving it empty.

AngularJS Reference Manual

❮ Angularjs Html Events Ng Ng Style ❯