Routing with AngularJs - angularjs

How to configure the route in AngularJS when the url contains query parameters. I have to write a config for handling route with the url /states?statename=kar. I wrote the config as /states?statename=:name but its not working. Can you please help me where I am going wrong?
If it was /states/statename/kar then I would have written the route with /states/statename:name.

Related

React URL Param routes failing on Amplify

I'm having issues with react url param routes and it's giving out error on amplify.
Example routes with url params
<AsyncSearchResultsList path="search/:q" />
<AsyncSearchDetailedInfo path="search/user/:id" />
This is the error I'm getting
On amplify I have these redirects setup
I can't navigate to either of these routes and it works fine for other routes without parameters
All of these routes are also working perfectly on localhost
Is there something I'm missing? I'm using Reach Router in my react project.
Update:
Figured what seemed to be part of it, the issue I was having was resolved. Amplify wasn't handling the Lazy loaded route components properly, data is flowing and the page is loading now after refactoring. But another issue came up, the page now displays blank whenever I navigate to those routes directly. I'm pretty sure it's an issue with Amplify's redirect rules. Still need help!
To those who need to use react and params
Source address
Target address
Type
Country code
</^[^.]+$|.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|woff2|ttf|map|json|webp)$)([^.]+$)/>
/index.html
200 (Rewrite)
-
/search?customer=<customerid>
/search?customer=<customerid>
301 (Redirect - Permanent)
-
Ref: https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#redirects-for-single-page-web-apps-spa
and
https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#query-parameters

Refresh page React-Laravel

I have a problem with my front-end in Reactjs(my back-end is in Laravel).
When I reload a pages, I have this error "Sorry, the page you are looking for could not be found."
I don't know why and how resolve this.
It's in my Router ?
Thanks for your help
You should have a configuration file respective to laravel for redirecting all the routes to index.html file.
The issue is that since you have react router which is an application's internal route, server thinks it as an external application path. So you should have a router forwarding configuration to serve index.html irrespective of the route.
In IIS it is done using web.config file.

nginx error pages not working in angular app using routes

I have an angular app that uses routes, where it has .otherwise(){} in routes.js file and now I need to make custom error pages using nginx, how to stop the .otherwise(){} and use the error pages defined on nginx default file, Anyone Please help I'm working on it from 5hrs. Or point me to any link that explains and solves this problem.
"Otherwise" in the routing is looking for a client side route. You can probably direct otherwise to a separate route on the client side with a controller that automatically redirects to a server route.
.otherwise('/ControllerThatSendsToServer');
Then in the ControllerThatSendsToServer just do a window.location = 'server error page';

How to change the url in smartAdmin AngularJs 1.8 version?

I am trying to change the path in the state routing in build/app.js but it loads the layout.tpl.html always with /dashboard url not loading the template with any other url. Please can anybody tell me how to change it ?
you can easily to to the app.config.js file and change the root of the URL

Spring MVC and AngularJS routing conflict

Hi Guys.
I have problem with routing between Spring MVC and AngularJS.
So, when I got homepage : http://localhost:8080/ captures that Angular and its ok but when i want go to another page e.g http://localhost:8080/dashboard captures that Spring MVC and Tomcat show error 404 Not Found.
To get to dashboard in need use url /#/dashbaord
Although i got below code in my file with routing configuration.
It is possible to angular was first taken into consideration and next Spring MVC?
$locationProvider.html5Mode({
enabled : true,
requireBase : false
});
Regards
You need to route all Tomcat URLs to index.html
For API calls to Spring Boot http://localhost:8080/springbootapi/wotever
And in Tomcat say DO NOT POINT ANY URL WITH /springbootapi/ in it to index.html
EVERYTHING ELSE TO index.html
Pointing everything else to index.html gives Angular full control over everything except API calls
The above outline the generic approach to do this.
Maybe better to follow this tutorial ...
https://spring.io/guides/gs/consuming-rest-angularjs/

Resources