routing

Redirect to different pages based on previous page in Laravel

冷暖自知 提交于 2019-12-10 13:29:15
问题 Imagine you have a method in controller, like storing a new company. Also imagine we can create new company from different pages in our site. For example, I can create a company from 2-3 pages. Depending on where I created the company I need to have different redirects. Sometimes I need to redirect back, and sometimes to other routes. Something like: if ($previousRoute === 'companies.index') { return redirect()->back(); } else { return redirect()->route('someroute'); } I guess I can't get the

Rails Routes - slash character vs hash character

倖福魔咒の 提交于 2019-12-10 13:18:15
问题 In urls and rails routing, what is the difference between using a slash character vs a pound sign (hash sign) character? These work get "/static_pages/about" get 'about', to: 'static_pages#about', as: :about These don't get "/static_pages#about" get 'about', to: 'static_pages/about', as: :about get 'about', to: '/static_pages#about', as: :about What code controls this behavior, and what is the deeper reason behind it? ANSWER: (The two people answered it very well, and I had trouble choosing

Angular 2 error: Cannot resolve all parameters for 'RouteParams'

浪子不回头ぞ 提交于 2019-12-10 13:04:24
问题 Trying to use RouteParams to get query-string parameters, but I just get the error Cannot resolve all parameters for 'RouteParams'(?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'RouteParams' is decorated with Injectable. angular2-polyfills.js:332 Error: Cannot read property 'getOptional' of undefined....... Check out this Plnkr. How can I use RouteParams without getting this warning? The important files are: boot.ts : import {bootstrap

AngularJS subdirectory routing not working, with <base> tag applied

陌路散爱 提交于 2019-12-10 12:42:23
问题 I've got an incredibly simple AngularJS template, I'm trying to get routing to work but when I load the page I'm just seeing the H1 tag from my index.html . My app is in a sub directory, /angular-route/ , and I know that the partials exist, I can visit /angular-route/partials/interest.html and the page renders fine. Have I missed something really basic here? <html> <head ng-app="myApp"> <title>AngularJS Routing</title> <base href="/angular-route/" /> </head> <body> <h1>AngularJS Routing</h1>

django rest framework - using detail_route and detail_list

谁都会走 提交于 2019-12-10 12:39:15
问题 In my code I have a viewset for the User. I want is to allow only Read operations ( /users/42 and /users/ ) which the ReadOnlyModelViewSet does just fine. In addition, I want to have a /users/register URL that I can POST to in order to register a new User. class UserViewSet(viewsets.ReadOnlyModelViewSet): queryset = User.objects.all() serializer_class = UserSerializer @list_route(methods=['post']) def register(request): serializer = UserSerializer(data=request.DATA) if serializer.is_valid():

Site navigation using ui-sref, how to remove ui-sref attribute when not available

自古美人都是妖i 提交于 2019-12-10 12:33:50
问题 I've setup navigation as follows, using ng-repeat, which works very well <a ui-sref="{{link.Route}}" ng-click="clickLink(link)"> <span class="title"> {{link.Text}} </span><span class="selected"></span> </a> However, my navigation items frequently have sublinks, which means the parent link isn't really a navigation link, it's just used to expand and view the sublinks. But sometime it is a link, and has no sublinks to display. The problem is for those particular cases, when there is no state

Why can't Asp.net MVC distinguish between two actions when they have different parameters?

匆匆过客 提交于 2019-12-10 12:31:26
问题 I am trying to have two different methods for account registration in my Asp.net MVC application, one for general users to register for and another for users who are registering with a specific registration token. Thus I have the following method signatures in my AccountController : public virtual ActionResult Register () {...} public virtual ActionResult Register (Guid registrationToken) {...} However, when I go to http://localhost/Account/Register I get an exception that the current request

Routing constraints don't assign values to a Rails parameter correctly; use '+' to delimit values

ⅰ亾dé卋堺 提交于 2019-12-10 12:10:41
问题 I would like to be able to support country codes and region codes in my application's routes. For example: /entities/us /entities/us+ca /entities/us/mn /entities/us/mn+wi+ia /entities/us+ca/bc+wa My current route: get "/entities/:country_code/(:region_code)" => "entities#index", :constraints => {:country_code=>/[a-zA-Z]{2}[\+\,]?/, :region_code=>/[a-zA-Z]{2}[\+\,]?/} resources :entities Trying /entities/us+ca results in this exception: # Use callbacks to share common setup or constraints

Angular stateParams to controller, $urlRouterProvider

一世执手 提交于 2019-12-10 11:19:18
问题 I'm building an app with Ionic and AngularJS. Now I have a page with a list of items. Each item has an ID, and so a click results in something like this: /item/1 or /item/2 where 1 and 2 are ID's. Now I have the default state like this, for the homepage with this list: .state('app.home', { url: "/home/", views: { 'menuContent': { templateUrl: "app/home.html" }, }, controller: 'HomeCtrl' }) What I want is to pass the paramater to the controller. What I found is the following solution, but this

How to get optional language parameter from URL in Express routes?

旧街凉风 提交于 2019-12-10 10:33:24
问题 I'm stuck with a stupid problem: How to work with optional locale parameter? That's what I mean: For example, I have frontpage and contacts , here is routes: app.get('/', frontpage.get); app.get('/contacts', contacts.get); Now I'm trying to add localization to my site app.all('/:lang?*', language.all); -> detect and set locale app.get('/:lang?', frontpage.get); app.get('/:lang?/contacts', contacts.get); The only problem is when I don't use lang-parameter in URL: mysite.com/contacts because