Fix double-click bug

Use $scope.$apply to notify Angular of changes to the model when
callbacks return from providers. Inline initTree function for
readability.