Comments (2)
Hi, there is nothing wrong with the extension, its just how an extension works.
You have to add "storage" permission to the manifest.json
"permissions": [
"tabs",
"storage"
]
After that it just works after clicking the button.
@Component({
selector: 'app-popup',
templateUrl: 'popup.component.html',
styleUrls: ['popup.component.scss']
})
export class PopupComponent implements OnInit {
message: string;
constructor(@Inject(TAB_ID) readonly tabId: number) {}
ngOnInit(): void {
chrome.storage.local.set({ favoriteCocktail: 'Daiquiri' })
}
async onClick(): Promise<void> {
this.message = await bindCallback<string>(chrome.storage.local.get.bind(chrome.storage.local, { favoriteCocktail: 'Daiquiri' }))()
.pipe(map((result) => result['favoriteCocktail']))
.toPromise();
}
}
from ng-chrome-extension.
Hey Larscom,
I had added storage to the permissions already, but my problem was still happening. I have now switched over to the await code you posted and indeed it is working with that. I find it rather strange though that when passing the chrome storage directly as observable instead of making it a promise and awaiting it, it's not working.
I tried to cast the "sendMessage" example from the scaffold directly into an Observable (without .toPromise and await) and that seemed to work perfectly. But for some reason the storage callback doesn't like to be an Observable. Anyway my problem is solved so thanks for your help!
from ng-chrome-extension.
Related Issues (20)
- Some thing doesn't work with Angular Material HOT 1
- Error: authentication required but no callback set HOT 7
- CSP error after upgrading from Angular 11 to 12 HOT 2
- npm install does not work on a mac HOT 3
- Project ignores Angular changes (watch not working) HOT 1
- Question: sharing common classes between layers HOT 1
- Access window.ethereum properties HOT 1
- Import primeng HOT 1
- I always get an error when I create a project with a "-" in the project name HOT 6
- Is there a wiki on how to update ng-chrome built extensions from manifest v2 to manifest v3 HOT 1
- Chnage Manifest file data based on environment/or with custom variables HOT 1
- Unable to add css urls and fonts in angular.json HOT 3
- Using the extension as addition to existing web page HOT 1
- Problem with npm i HOT 1
- npm start not running on any port HOT 1
- JQuery plugin not working HOT 1
- Build scripts -> "ng build --configuration='development'" HOT 4
- load angular as content script
- how to load script like jquery.min.js into serviceWorker.ts
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ng-chrome-extension.