routing

Named routes in param pre-conditions

纵饮孤独 提交于 2019-12-08 18:44:28
I'd like to use a Route Param Pre-Condition to fetch portfolio items by "slug" if the :slug parameter is set in the URL. I also, however, would like to use a RegExp to match the URI. Are named captures supported in node? Can I give that ([-\w]+) capture a name so the slug pre-condition gets fired? app.param('slug', function(req, res, next, slug){ // get thing from database by slug }) //app.get('/work/view/:slug', function(req, res){ app.get(/^\/work\/view\/([-\w]+)/, function(req, res){ // render view }) I'm not sure if this is what you are looking for, but as far as I know, there is no direct

Angular 4 function that calls route

老子叫甜甜 提交于 2019-12-08 18:40:31
I have routing set up through a menu in my Angular web-app. The menu has routerLinks set up like the home link below: <a routerLink="home"> <button md-menu-item> <md-icon class="material-icons"> home </md-icon> <span> Home </span> </button> </a> The app.router contains: export const router: Routes = [ { path: '', redirectTo: 'home', pathMatch: 'full'}, { path: 'home', component: HomeComponent }, ]; I want to have a button in a component that redirects to an enquiry form that is not available in the normal menu, but placing an link on a button in the component does not seem to work. Why is this

Navigate in Angular 7 without adding parameter to URL

时光毁灭记忆、已成空白 提交于 2019-12-08 17:11:52
问题 I want to navigate between two routes in Angular 7 with posting data between them. But I don;t want to show those parameter in URL. How to do it in proper way? at this moment I am strugging with something like this: this.router.navigate(['/my-new-route', {data1: 'test', test2: 2323, test: 'AAAAAAA'}]); and it change my url to http://localhost:4200/my-new-route;data1=test;test2=2323;test=AAAAAAA how to do it to cancel those data from url: http://localhost:4200/my-new-route Edit: My case: /form

Rails 3 Routing - How to use scope to create admin prefix

独自空忆成欢 提交于 2019-12-08 17:11:33
问题 I'm using this Rails Guide to create a scope in order to create an "/admin" prefix for some controllers. So I have a controller named Pages, I want to access it via "/admin/pages". scope "/admin" do resources :pages end That works great, but it is still accessible via "/pages" ... How do I prevent that? (I'm using Rails 3) Here's my routes file: devise_for :users scope "/admin" do resources :pages resources :contents end root :to => "index#index" match ':controller(/:action(/:id(.:format)))'

Programmatically adding routes to Backbone.Router?

痴心易碎 提交于 2019-12-08 17:07:26
问题 Here is my application-router.js file where i'm creating Backbone.Router object with just only few routes: var App = App || {}; App.Router = Backbone.Router.extend({ routes : { '' : 'showDashboard', // Not shown '*other': 'showModalError' }, defaultRoute : function(other) { $('#modal404').modal(); } }); In main javascript file application.js i'd like to programmatically add routes. I've tried with route() function and it doesn't work, routes are not added. It works however passing an object

How to test controllers with nested routes using Rspec?

浪尽此生 提交于 2019-12-08 16:51:49
问题 I have 2 controllers that I created using scaffold generator of rails. I wanted them to be nested in a folder called "demo" and so ran rails g scaffold demo/flows rails g scaffold demo/nodes Then I decided to nest nodes inside flows, and changed my routes file like so: namespace :demo do resources :flows do resources :nodes end end But this change resulted on the rspec tests for nodes breaking with ActionController::Routing errors. 15) Demo::NodesController DELETE destroy redirects to the

Issue in rails 4.0 with creating a link_to for a delete action

梦想的初衷 提交于 2019-12-08 16:47:24
问题 This is my first project in rails, which is to create a table that will store data about games. I'm able to display data from the table about winner score, loser score, etc. However, I have issues with my table column that contains delete links for each game. Here's my code in the games controller for the delete method: def delete @game = Game.find(params[:game]) @game.destroy() redirect_to :action => 'index' end A snippet of my table code, which includes the line for the link_to command <%

WebApi optional parameter - is required?

最后都变了- 提交于 2019-12-08 16:38:38
问题 I have a web api controller (TasksController) with a get method like : public IEnumerable<TimeUnitModel> Get(DateTime startDate, DateTime endDate, string projectCode = "") If I call /api/tasks?startDate=2012%2F12%2F08&endDate=2012%2F12%2F15 the correct result is returned. If I call /api/tasks?startDate=2012%2F12%2F08&endDate=2012%2F12%2F15&projectCode= then I get : {"projectCode.String":"A value is required but was not present in the request."} Any idea why this happens ? Thanks. Edit: Here's

rerouting in views MVC3

回眸只為那壹抹淺笑 提交于 2019-12-08 14:28:08
问题 I have in my views dir two folders: nl and eng. In every dir there is a home, account. One in dutch and 1 in english. But how can I route default to nl-pages and by clicking to a link using the eng-pages. Then I want to use cookies to set default to a languages. thanks in advance. Cheers 回答1: I would recommend you going through the following guide. 来源: https://stackoverflow.com/questions/6329288/rerouting-in-views-mvc3

Single page application routing w/ Crossroads & Hasher, by example

旧街凉风 提交于 2019-12-08 14:14:15
问题 I am trying to write my first single-page application. The idea is to have 1 HTML file that contains many <div> tags; where each <div> represents a single web "page". Then the application just shows 1 <div> at a time, and hides the others. In this way, as users navigate my app, I'm really just showing/hiding different "page" divs, and giving the illusion of a single page app. Additional requirements are: This is an HTML5 app Each page div must map too its own bookmarkable URL ( http://myapp