Skip to content

Instantly share code, notes, and snippets.

@ryangasparini-wf
Last active December 11, 2015 05:19
Show Gist options
  • Save ryangasparini-wf/4551847 to your computer and use it in GitHub Desktop.
Save ryangasparini-wf/4551847 to your computer and use it in GitHub Desktop.
Viewer Controller Flow
// get all books
scope.books = Books.getBooks();
// test if route included revision
if (!routeParams.bookRevision) {
// test if route included book key
if (!routeParams.bookKey) {
// take first book from the collection
scope.book = scope.books[0];
// TODO: this is where we would call updatePath for bookKey
} else {
// find book in collection by key
scope.book = scope.books.find('key', routeParams.bookKey);
}
} else {
// make sure there is a bookKey for the revision
if (!routeParams.bookKey) {
throw 'Revisions require a valid book key.'
}
}
// test for rootid or revision
if (!book.rootid || routeParams.revisionKey) {
scope.book = Books.getBook(book);
}
// now get all the tabs
scope.tabs = Tabs.getTabs(book);
// test if there isn't a tab
if (!routeParams.tabKey) {
// take first tab from collection
scope.tab = scope.tabs[0];
// TODO: this is where we would call updatePath for tabKey
} else {
// find tab in collection by key
scope.tab = scope.tabs.find('key', routeParams.tabKey);
}
@johnbland-wf
Copy link

So updating the path on line 10 essentially accomplishes the same effect of what we have now. Why not way until we have the book, revision, and tab keys together/determined to update the url?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment