I have routing code of the following nature in Express :
app.get("/profile/:param", function (req, res)
This is coinciding with the path routing provided by AngularJS. For instance, when an Angular view of the nature /profile/someparam#view1
is loaded,the new URL pattern is picked up by Express, which assumes it to be of the type /profile/<someparam>
. This is causing the controller associated with view1 to be called infinitely thereby crashing the page.
How do I get around this problem?
I was able to find the solution from here: AngularJS and ExpressJS routing conflicts . Basically, in the angular routing file, the templateURL
needs to be pre-pended with a '/'. For eg, in my angular routing code, I had to change
$routeProvider.when('/routeName', {
templateUrl: 'view1.html',
controller:'rcontroller'
});
to
$routeProvider.when('/routeName', {
templateUrl: '/view1.html',
controller:'rcontroller'
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.