I'm trying to write a Chrome Extension using Angular 2.
In my app.component.ts
, I have the following:
import { Component } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'my-app',
templateUrl: 'app.component.html'
})
export class AppComponent {
showHeading = true;
heroes = ['Magneta', 'Bombasto', 'Magma', 'Tornado'];
toggleHeading() {
this.showHeading = !this.showHeading;
}
injectHello(){
chrome.runtime.sendMessage({action:"inject"});
}
}
The problem is that when I try to compile using Ahead of Time compilation, I get this error:
Error at /dev/quickstart/app/app.component.ts:14:12: Property 'runtime' does not exist on type 'typeof chrome'.
Apparently, my angular app does not know about chrome.runtime. What is the best way to resolve this?
I've seen this stack overflow answer about compiling chrome-app.d.ts with tsc
, but I need to use Ahead of Time compilation to get around the Content Security Policy.
Therefore, I use node_modules/.bin/ngc -p tsconfig-aot.json
instead of tsc
. Any help?