Given that Angular is tied to the views and bootstrapped in the main extension view, I assume the simple answer is "No, not possible", but wanted to confirm as I can't find a definitive answer anywhere.
My use case is that the extension will be polling for updated content from an API, and updating the extension's badge when found; I'd love to be able to re-use my API service from the extension's Angular codebase.
If not possible, any suggested workarounds for sharing code between the Angular extension and the background script?
Thanks for the input @Xan, @harish - based on your feedback did some more investigation and have the solution. In essence, instead of pointing to a background script in the Chrome manifest, I am pointing to a background HTML page, which I then use to bootstrap my Angular app. The relevent code:
manifest.json:
...
"background": {
    "page": "/app/background.html"
}
...
background.html
<!DOCTYPE html>
<html lang="en" ng-app="MyApp" ng-csp>
    <head>
        <title>Background Page</title>
        <meta charset="UTF-8">
        <script type="text/javascript"
            src="/app/components/angular/angular.js"></script>
        <script type="text/javascript"
            src="/app/scripts/background.js"></script>
    </head>
    <body></body>
</html>
background.js
var app = angular.module('MyApp', []);
app.run(function() {
  console.log('Hello world');
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With