I wanted to create a Chrome Extension for starters. I'm a bit stuck because I do not know how to make my extension run in the background.
I have researched an answer for my issue but I haven't identified a suitable solution.
The logic of my extension is in AngularJS controller files. I do not know how to create the background.js file to communicate with my AngularJS controller files or even if it's necessary to have one.
I would like the extension logic to run even when the popup does not appear in view (eg modHeaders app).
The manifest file is:
"manifest_version": 2,
"name": "Chrono",
"version": "1.1",
"description": "Reminder",
"browser_action": {
"default_icon": "images/timerIcon.png",
"default_popup": "index.html",
"default_title": "ChronoBip"
},
"background": {
"scripts": ["background.js"],
"persistent": false
},
"permissions": [
"background",
"tabs" ]
}
If you need more info, please tell me.
Instead of running separate .js
file(background.js), try running your controller JS file as your background scripts. See if it works.
Here I placed my controller(myAppCtrl.js) file in background.
"manifest_version": 2,
"name": "Chrono",
"version": "1.1",
"description": "Reminder",
"browser_action": {
"default_icon": "images/timerIcon.png",
"default_popup": "index.html",
"default_title": "ChronoBip"
},
"background": {
"scripts": ["app/controllers/myAppCtrl.js"],
"persistent": false
},
"permissions": [
"background",
"tabs" ]
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.