Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using AngularJS in a Google Chrome extension

Tags:

I am trying to use the Google developer AngularJS library in an extension popup, but I get an error.

Error: Code generation from strings disallowed for this context at Function (unknown source) at Jb (chrome-extension://jambnlbfljcfpomlclcgphfmkjfiphkb/lib/angular.js:74:18) at k (chrome-extension://jambnlbfljcfpomlclcgphfmkjfiphkb/lib/angular.js:62:357) at Jc (chrome-extension://jambnlbfljcfpomlclcgphfmkjfiphkb/lib/angular.js:64:37) at Lc (chrome-extension://jambnlbfljcfpomlclcgphfmkjfiphkb/lib/angular.js:69:166) at chrome-extension://jambnlbfljcfpomlclcgphfmkjfiphkb/lib/angular.js:74:241 at chrome-extension://jambnlbfljcfpomlclcgphfmkjfiphkb/lib/angular.js:51:270 at F (chrome-extension://jambnlbfljcfpomlclcgphfmkjfiphkb/lib/angular.js:47:339) at X (chrome-extension://jambnlbfljcfpomlclcgphfmkjfiphkb/lib/angular.js:39:390) at t (chrome-extension://jambnlbfljcfpomlclcgphfmkjfiphkb/lib/angular.js:38:286)

What is the proper way to write the following content_security_policy directive for a Google Chrome plugin manifest file?:

"content_security_policy": "default-src 'self'; script-src 'unsafe-eval' 'unsafe-inline'; style-src 'unsafe-inline'", 

currently it is throwing an error...

like image 990
Victor S Avatar asked Jul 05 '12 01:07

Victor S


People also ask

Can we use angular for Chrome extension?

You can find Angular DevTools in the Chrome Web Store and in Firefox Addons. After installing Angular DevTools, find the extension under the Angular tab in your browser DevTools. Lets you explore the components and directives in your application and preview or edit their state.

How do I inspect AngularJS in Chrome?

If you're using Chrome, we can use a shortcut with the developer tools. Simply find the element you're interested in, right click on it in the browser, and select inspect element. The element itself is stored as the $0 variable, and we can fetch the Angular-ized element by calling: angular. element($0) .

What is the extension of AngularJS?

AngularJS extends HTML with ng-directives.


1 Answers

You have to use CSP mode in angular to be inside Chrome extension. See: https://github.com/angular/angular.js/issues/893

Basically you have to declare your app as:

<html ng-app="" ng-csp> 
like image 68
Misko Hevery Avatar answered Sep 25 '22 22:09

Misko Hevery