I
I
Ivan Chernov2016-07-12 23:50:23
Angular
Ivan Chernov, 2016-07-12 23:50:23

How to use links in text as internal routing in AngularJS?

There is a mobile application on Ionic, which essentially uses just Angular. Receives the news text from the server via json api. The news body can contain links to other news, for example /articles/id... .
How to use them?
I enabled html5mode like this:

$locationProvider.html5Mode({
  enabled: true,
  requireBase: false
});

In the hope that they will be treated as normal links, but they work as a route not found.
Is it possible to somehow get ui-sref from them?
Or any other way to use relative links within text, like internal application links.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2016-07-12
@peanut

Display the text of the news through the directive where you find all the links and replace them in such a way that they open through ui-sref. Or, passing through the interceptor, replace the links. I would use the second option.
I don't see any other way.
**************************************************
Text of the article:
We replace with:
And we rejoice)))
But how to get the parameters in the router - this is your homework))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question