Skip to content

Allow passing null to query-params subexpression #10772

@blimmer

Description

@blimmer

It would be really great if you could pass null to the query params subexpression in a link-to. Today, if I pass null like this:

{{#link-to 'foo' (query-params test=null)}}...{{/link-to}}

I will end up on the route localhost:4200/foo?test=undefined because the subexpression is expecting null to be a variable it can access in my current context.

A common use case of doing something like this is with clearing a search. Imagine I've implemented a search query parameter and I want to implement an "X" to clear the search. In order to use a link-to and clear the query parameter, I have to put a variable called null in context for the link-to to clear the query param from the address bar.

App.FooController = Ember.Controller.extend({
  queryParams: [q],
  q: null,
  null: null
});

Here's an example JSBin showing the issue I described.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions