Skip to content

Instantly share code, notes, and snippets.

@congjf
Last active August 29, 2015 13:56
Show Gist options
  • Save congjf/9205024 to your computer and use it in GitHub Desktop.
Save congjf/9205024 to your computer and use it in GitHub Desktop.
AngularJS in Chrome Extension
// Call Chrome API
function MyController($scope){
chrome.bookmarks.getTree(function(tree){
// Here MUST use $scope.$apply() for Render the data updated to View.
$scope.$apply(function(){
$scope.tree = tree[0].children;
});
});
}
// Call Chrome API with Event
function MyController($scope) {
$scope.showBookmarks = chrome.bookmarks.getTree(function(tree){
$scope.tree = tree[0].children;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment