An angular library that handles the checking if extension specified is installed or not, it also allows you to trigger inline installation with the right configuration.
- Go to your project directory using your command line tool then install the project using npm.
npm install angular-web-extension-handler
- Include angular.js and angular-web-extension-handler.js to your index page.
<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript" src="angular-web-extension-handler.js"></script>
- Add the ngErrorHandler module to you application.
angular.module('myApp', ['ngWebExtensionHandler']);
- You can now use the 'webExtensionHandlerProvider' to setup your extension details.
angular.module('myApp').config(function (webExtensionHandlerProvider) {
webExtensionHandlerProvider.config({
chrome: {
id: 'chromeExtensionId',
url: 'https://chrome.google.com/webstore/detail/chromeExtensionId',
iconUrl: 'chrome-extension://chromeExtensionId/icon.png'
},
firefox: {
name: 'The label that will appear on inline installation popup',
url: 'https://addons.mozilla.org/firefox/downloads/latest/youraddon',
iconUrl: 'resource://@youraddon/icon.png'
}
});
});
- After the configuration you can now use the 'install' and 'isInstalled' method.
angular.module('myApp').controller(function (webExtensionHandler) {
var vm = this;
vm.checkIfExtensionIsInstalled = function () {
webExtensionHandler.isInstalled().then(function () {
// Already installed
}, function () {
// Not yet installed
});
};
// This should be triggered by user gesture, e.g. click
vm.installExtension = function () {
// If firefox is the browser being used the callback will not be called
// because your site should be whitelisted to the MDN
webExtensionHandler.install().then(function () {
// Installed successfully
}, function () {
// User cancelled
});
};
});
This project is licensed under the MIT License - see the LICENSE file for details
- Unit tests
- Support for other browsers