Skip to content
This repository was archived by the owner on May 23, 2019. It is now read-only.
This repository was archived by the owner on May 23, 2019. It is now read-only.

How does Back button retain previous search? #30

@bjnord

Description

@bjnord

[Couldn't find a way to contact you directly; hope it's OK that I ask this here. If I had this question, other readers might too.]

Thanks for your book; this was a really helpful introduction to AngularJS with RoR. When I was all done, there was just one thing that puzzled me. The 'Back' button is defined as:

<button ng-click="back()" class="btn btn-default">

and clicking that calls the back() function in RecipeController which looks like this:

$scope.back   = -> $location.path("/")

The behavior you see in the browser (and that the specs validate is happening) is that when you click 'Back' you not only return to the root path, but the keywords you used in the previous search are still there. To achieve this I would have expected something like:

$scope.back   = -> $location.path("/").search('keywords', keywords)

as it's done in RecipesController. Is there some magic about $location.path(...) that preserves whatever URL parameters there were before, or is there something else that accomplishes it? What would you do if you wanted a link/button that took you to the root path and cleared any previous keywords?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions