routing

Passive Link in Angular 2 - <a href=“”> equivalent

南楼画角 提交于 2019-11-28 17:20:50
In Angular 1.x I can do the following to create a link which does basically nothing: <a href="">My Link</a> But the same tag navigates to the app base in Angular 2. What is the equivalent of that in Angular 2? Edit: It looks like a bug in the Angular 2 Router and now there is an open issue on github about that. I am looking for an out of the box solution or a confirmation that there won't be any. Emiel Koning If you have Angular 5 or above, just change <a href="" (click)="passTheSalt()">Click me</a> into <a [routerLink]="" (click)="passTheSalt()">Click me</a> A link will be displayed with a

Routing: 'admin' => true vs 'prefix' => 'admin in CakePHP

徘徊边缘 提交于 2019-11-28 17:06:39
Hi I'm setting up admin routing in CakePHP. This is my current route: Router::connect('/admin/:controller/:action/*', array('admin' => true, 'prefix' => 'admin', 'controller' => 'pages', 'action' => 'display', 'home')); It works fine, but I don't understand what the difference between 'admin' => true, and 'prefix' => 'admin' is. When I omitted 'prefix' => 'admin' , the router wouldn't use admin_index and would instead just use index . So what's the point of 'admin' => true ? By setting 'prefix' => 'admin' you are telling CakePHP that you want to use a prefix of admin for that route; basically

Laravel previous and next records

落爺英雄遲暮 提交于 2019-11-28 17:05:26
I am trying to create a page where I can see all the people in my database and create edits on them. I made a form where I fill in the data from the database of certain fields. I would like to navigate trough them by a Next and Previous button. For generating the next step I have to take the ID larger than the current one to load the next profile. For generating the previous step I have to take the ID smaller than the current one to load the previous profile. My route: Route::get('users/{id}','UserController@show'); Controller: public function show($id) { $input = User::find($id); // If a user

Custom Error Pages in Rails?

本秂侑毒 提交于 2019-11-28 17:04:47
I need to implement a custom error page in my rails application that allows me to use erb. I've been following this tutorial ( http://blog.tommilewski.net/2009/05/custom-error-pages-in-rails/ ) and I cannot get it to work locally (or remotely). I am running Rails 2.3.5 Here's the gist of the approach. 1) in the 'application_controller', I over ride the "render_optional_error_file(status_code)" method, and set the visibility to "protected", like this. protected def render_optional_error_file(status_code) known_codes = ["404", "422", "500"] status = interpret_status(status_code) if known_codes

Creating routes with an optional path prefix

可紊 提交于 2019-11-28 16:53:31
How can I go about making my routes recognise an optional prefix parameter as follows: /*lang/controller/id In that the lang part is optional, and has a default value if it's not specified in the URL: /en/posts/1 => lang = en /fr/posts/1 => lang = fr /posts/1 => lang = en EDIT Ideally, I'm looking to do this across many controllers and actions by mapping a namespace: map.namespace "*lang" do |lang| lang.resources :posts lang.resources :stories end OK, I've managed to sort out this problem: THere is no way of doing this in Rails by default (at least, not yet). Instead of using namespaces and

How to remove controller names from rails routes?

ⅰ亾dé卋堺 提交于 2019-11-28 16:48:01
问题 I would like to trim down the routes on my application so that: http://myapplication.com/users/peter/questions/how-do-i-create-urls becomes... http://myapplication.com/peter/how-do-i-create-urls I have a users controller and would like it to be resourceful. Users also have a nested resource called questions. Basic routes file Without any URL trimming, the routes file looks like this: ... resources :users do resources :questions end However the URLs from this take the form of http:/

Rails: how do you access RESTful helpers?

一个人想着一个人 提交于 2019-11-28 16:44:00
问题 I'm trying to work through this guide to Rails routing, but I got stuck in section 3.3: Creating a RESTful route will also make available a pile of helpers within your application and then they list some helpers like photos_url , photos_path , etc. My questions: Where can I find the complete list of helpers that is "made available?" Is there a way to call the helpers in the console? I created an app, then opened up the console with script/console . I tried to call one of the helpers on the

How do I do geocoding and routing with OpenStreetMap? [closed]

丶灬走出姿态 提交于 2019-11-28 16:43:06
Because Google Maps API is not available in Israel (see here ) I want to use OpenStreetMap. I'm confused by all the different ways to do geocoding, i.e. finding lat,long for an address. I'm also looking for the best way to do routing, i.e. display a route between two locations, using OSM. I'm looking for JavaScript on the client and .NET on my server. I'm also looking for a solution that will work with names in Hebrew, but I do not think this is a limitation. Routing MapQuest open offers an Open Directions Service and an Open Guidance Service . Additional information about Routing in

Redirect (301) one route to another from routing.yml in Symfony2

▼魔方 西西 提交于 2019-11-28 16:32:50
I know this is probably trivial, but I couldn't find anything on the web or in the Symfony2 reference. How do I redirect one route to another from routing.yml (with 301 status code)? I'm looking for something like this: SomeRoute: pattern: /someroute defaults: { _controller: SomeBundle:Controller:action } AnotherRoute: pattern: /anotherroute defaults: { _redirect: {route: SomeRoute, status: 301} } I could create a controller, but it seems overkill, since I don't have any parameters (and it would be overkill even so, if they are to be passed as they are). SomeRoute: pattern: /someroute defaults

Setting ajax url for jQuery in JS file using ASP.NET MVC

限于喜欢 提交于 2019-11-28 16:01:10
When doing a Ajax call to an MVC action currently I have my javascript inside the View, not inside its own JS file. It is then very easy to do this: var xhr = $.ajax({ url: '<%= Url.Action("DisplayItem","Home") %>/' + el1.siblings("input:hidden").val(), data: { ajax: "Y" }, cache: false, success: function(response) { displayMore(response, el1, xhr) } }); ...then including the URL in the ajax call using Url.Action() inside the JS is pretty easy. How could i move this do its own JS file when without hard coding the URL? This way fully uses MVC Routing so you can fully take advantage of the MVC