Created
May 29, 2014 22:00
-
-
Save corburn/24b78ad09ecbcf141ff7 to your computer and use it in GitHub Desktop.
Use AngularJS module in Chrome Extension eventPage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The first array is an array of angular modules. The ng module is optional. | |
// It is normally implicitly included and provides access to the angular API. | |
// The second array is the module components that will be injected as parameters | |
// to the final element which is a function. | |
angular.injector(['ng', 'myModule']).inject(['myModuleFactory', ..., eventCtrl]); | |
// This is where the event handlers are registered | |
function eventCtrl(myModuleFactory) { | |
chrome.tabs.onCreated.addListener(myModuleFactory.doStuff); | |
// ... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
background: { | |
scripts: [ | |
"bower_components/angular/angular.js", | |
"js/myModule.js" | |
"js/eventPage.js" | |
], | |
persistent: false | |
}, | |
manifest_version: 2, | |
name: "myExtension", | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myModule', []) | |
.factory('myModuleFactory', function() { | |
return { | |
doStuff: function(args) { | |
// ... | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment