Last active
November 1, 2018 12:43
-
-
Save lcpriest/db74e742c632372479bee8a65af85825 to your computer and use it in GitHub Desktop.
Revisions
-
lcpriest revised this gist
Aug 5, 2017 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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>` -
lcpriest revised this gist
Aug 5, 2017 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 } ``` -
lcpriest created this gist
Aug 5, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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)}} ```