Search Posts

Is it possible to use router.get after having been using ngRoute?

I’ve been using Angular’s ngRoute and .when for displaying the hmtl routes of my application. For this I have configured a main route:

var appRoutes = require('./backend/routes/api');

I was trying to add another route this way but most of the html wasn’t displaying correctly, so I configured another main route:

var questions = require('./backend/routes/questions');

in the file where I use Angular’s ngRoute with .when, I added a route for /questions but it doesn’t load it properly (some elements are not shown). That’s why in the questions.js file where I configure the /questions route, I’m using router.get to render the questions.html page.

Using both .when and router.get makes it work but only after reloading the browser once I’m on the correct URL(

If I only use .when it takes me to the page that doesn’t load properly, and if I use only router.get it doesn’t load it at all.

Is there a way to fix this?

Source: AngularJS

Leave a Reply

Your email address will not be published. Required fields are marked *