AngularJS ng-csp instruction
Definition and usage
ng-csp
instruction is used to change AngularJS's security policy.
setting ng-csp
After the
will ng-csp
The value of the no-unsafe-eval
, which will prevent AngularJS from running any eval functions, but allow the injection of inline styles.
will ng-csp
The value of the no-inline-style
, which will prevent AngularJS from injecting any inline styles, but allow eval functions.
When developing applications for Google Chrome extensions or Windows applications, it is necessary to use ng-csp
Instruction.
Note:ng-csp
The instruction does not affect JavaScript, but it changes the way AngularJS works, which means: you can still write eval functions, and they will execute as expected, but AngularJS will not run its own eval function. It uses a compatibility mode that may slow down evaluation time by up to 30%.
Παράδειγμα
Αλλάξτε τη συμπεριφορά του AngularJS στις πτυχές "eval" και inline style:
<body ng-app="" ng-csp> ...
Γλώσσα
<element ng-csp="no-unsafe-eval | no-inline-style"></element>
Παράμετροι
Παράμετροι | Περιγραφή |
---|---|
|
Η τιμή μπορεί να είναι κενή, που σημαίνει ότι δεν επιτρέπεται ο eval και ο inline style. Η τιμή μπορεί να είναι μια από τις δύο τιμές που περιγράφονται. Η τιμή μπορεί να είναι δύο τιμές, χωρισμένες με τελεία, αλλά έχει την ίδια σημασία με το κενό. |