Skip to content

Instantly share code, notes, and snippets.

@lcpriest
Last active November 1, 2018 12:43
Show Gist options
  • Select an option

  • Save lcpriest/db74e742c632372479bee8a65af85825 to your computer and use it in GitHub Desktop.

Select an option

Save lcpriest/db74e742c632372479bee8a65af85825 to your computer and use it in GitHub Desktop.

Revisions

  1. lcpriest revised this gist Aug 5, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions dynamic-query-params.md
    Original file line number Diff line number Diff line change
    @@ -33,3 +33,5 @@ let dynamicQueryParameters = {
    graphs: false
    }
    ```
    Will generate
    `<a href="https://yourapp.com/dashboard?superCoolMetrics=true&graphs=false">test-link</a>`
  2. lcpriest revised this gist Aug 5, 2017. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions dynamic-query-params.md
    Original file line number Diff line number Diff line change
    @@ -24,3 +24,12 @@ Usage:
    ```
    {{link-to 'test-link' params=(dynamic-params routeName dynamicQueryParameters)}}
    ```

    Where
    ```
    let routeName = 'dashboard';
    let dynamicQueryParameters = {
    superCoolMetrics: true,
    graphs: false
    }
    ```
  3. lcpriest created this gist Aug 5, 2017.
    26 changes: 26 additions & 0 deletions dynamic-query-params.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    I was attempting to generate a list of links and found that some of them needed query params and others didn't.
    I could not find a recommended way to pass in a dynamic query-params object to the link-to helper.
    I ended up finding a solution in the [Ember Discourse](https://discuss.emberjs.com/t/passing-dynamic-query-params-as-an-object-in-link-to-helper/9136/3?u=lcpriest) and decided to make it into an ember helper.

    Helper:
    ```
    import Ember from 'ember';
    export function dynamicParams([routeName, params]/*, hash*/) {
    return [
    routeName,
    {
    isQueryParams: true,
    values: params
    }
    ];
    }
    export default Ember.Helper.helper(dynamicParams);
    ```

    Usage:

    ```
    {{link-to 'test-link' params=(dynamic-params routeName dynamicQueryParameters)}}
    ```