I am trying to learn about Chrome extensions and am having some trouble. I am trying to get a list of my bookmarks using chrome.bookmarks
api but I am having trouble getting the actual values where I can manipulate them.
I have this simple angular module:
angular.module('bookmarkapp', [])
.controller('mainctrl', function($scope) {
$scope.tree = [];
dumpBookmarks();
console.debug($scope.tree);
function dumpBookmarks() {
$scope.bookmarkTreeNodes = chrome.bookmarks.getTree(
function(bookmarkTreeNodes) {
console.debug(bookmarkTreeNodes)
$scope.tree = bookmarkTreeNodes;
});
}
});
And I want to get the tree structure object into the $scope.tree
variable. When I do console.debug(bookmarkTreeNodes)
I get the values of the bookmarks, but when I try and set it equal to $scope.tree
and print that out I can't. I am not that new to js and angular but I seriously don't know why this wouldn't work.
EDIT here is a bookmarkTreeNodes structure
Array [3]
Array[0]
children : Array[17]
title : "bookmarks bar"
Array[1]
children : Array[0]
title : "Other bookmarks"
Array[2]
children : Array[1]
title : "Mobile Bookmarks"
Here is the html using the controller:
<body ng-app="bookmarkapp" ng-controller="mainctrl">
<div class="row">
<div class="col s12">
<div class="card grey darken-1">
<div class="card-content white-text">
<span class="card-title">Card Title</span>
<h4 data-ng-repeat="item in bookmarks">{{item.title}}</h4>
</div>
</div>
</div>
</div>
<script src="script.js"></script>
</body>