docs(ngCsp): add more informative details

Transferred from https://github.com/angular/angular.js/wiki/Using-AngularJS-in-a-Chrome-Extension-environment
This commit is contained in:
Dean Sofer 2013-05-15 23:17:30 -07:00 committed by Pete Bacon Darwin
parent 73aaca05f8
commit 9a73d71f47

View file

@ -5,16 +5,32 @@
* @name ng.directive:ngCsp * @name ng.directive:ngCsp
* @priority 1000 * @priority 1000
* *
* @element html
* @description * @description
* Enables [CSP (Content Security Policy)](https://developer.mozilla.org/en/Security/CSP) support. * Enables [CSP (Content Security Policy)](https://developer.mozilla.org/en/Security/CSP) support.
* This directive should be used on the root element of the application (typically the `<html>` *
* element or other element with the {@link ng.directive:ngApp ngApp} * This is necessary when developing things like Google Chrome Extensions.
* directive). *
* * CSP forbids apps to use `eval` or `Function(string)` generated functions (among other things).
* If enabled the performance of template expression evaluator will suffer slightly, so don't enable * For us to be compatible, we just need to implement the "getterFn" in $parse without violating
* this mode unless you need it. * any of these restrictions.
* *
* @element html * AngularJS uses `Function(string)` generated functions as a speed optimization. By applying `ngCsp`
* it is be possible to opt into the CSP compatible mode. When this mode is on AngularJS will
* evaluate all expressions up to 30% slower than in non-CSP mode, but no security violations will
* be raised.
*
* In order to use this feature put `ngCsp` directive on the root element of the application.
*
* @example
* This example shows how to apply the `ngCsp` directive to the `html` tag.
<pre>
<!doctype html>
<html ng-app ng-csp>
...
...
</html>
</pre>
*/ */
var ngCspDirective = ['$sniffer', function($sniffer) { var ngCspDirective = ['$sniffer', function($sniffer) {