1

I am trying to link to a section in another route. I looked online and cannot find a way to do this basic function in Ember JS.

I have tried:

href="someRoute#section" // does not work

and

<LinkTo @route="someRoute#section">Link</LinkTo> // someRoute#section route does not exist 

Does anyone know of a way of getting this to work. I am using Ember Octane so I can use anything available in there to help.

Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
UXCODA
  • 1,118
  • 2
  • 18
  • 33
  • 2
    `` component only accept a route name ==> https://github.com/emberjs/ember.js/blob/925bee3eda2f31083f4e96ed653e9f7f8cb19a02/packages/%40ember/-internals/glimmer/lib/components/link-to.ts#L280, but you can use `queryParams` to send element id for scroll and then use html api to scroll the page... or use some addons like this ==>https://github.com/peopleconnectus/ember-concurrency-scroll – Denis Nazarenko Jun 18 '19 at 09:24

2 Answers2

1

you may use this addon ember-href-to and use this like

Click here to see about the above addon. Nice example is available there. you may refer those.

Bhabani P
  • 1,061
  • 7
  • 4
1

Ember does not have a native way to link to particular elements in the DOM. This is true for both the angle-bracket <LinkTo /> component and the curly component {{#link-to}}. There does, however, seem to be a hack to provide this feature -> Ember.js anchor link.

mattbeiswenger
  • 383
  • 3
  • 11