routing

Angular 4 routes are calling ngOnInit every time component is loaded repeating API call

核能气质少年 提交于 2020-01-16 18:08:17
问题 I have a little webapp that basically lists a player list and when user clicks on the player name, it shows player details. It uses two api calls, one for list and other to load details of selected player. My problem is that when i go back from details route to home route the component executes ngOnInit again so it makes again the first api call to load the home list again, and i don't want this call again. This is my configuration: routing.module.ts ... export const routes: Routes = [ { path

Passing parameters in hug server as /foo/something in double number function

ぃ、小莉子 提交于 2020-01-16 12:02:07
问题 I want to get the double of one number when I access to URL /double/<number> in hug server. Something like routing in flask. Is it possible to do that? In documentation of hug server, I did not found nothing: My code would seem like: @hug.get('/double', number) def doubles(n): return 2*n 回答1: Yup, you can do: import hug @hug.get("/double/{number}") def doubles(response, number: hug.types.number): return 2 * number Note, that if you don't define type it will default to string . 来源: https:/

Lazy load modules on same path based on role

本秂侑毒 提交于 2020-01-16 05:14:50
问题 I am trying to load an Angular Module based on my role (when I am logged in). I tried it with an Angular Guard but that is not working, when it fails it does not go to the next route. const routes: Routes = [ { path: '', loadChildren: () => AuthModule // Load when not logged in }, { path: '', loadChildren: () => AdminModule // Load when admin }, { path: '', loadChildren: () => CrewModule // Load when crew } ]; Any ideas for how to fix this? I think an Angular Guard or using a matcher is not

Trouble on setting the ':controller' parameter for a 'link_to' statement

我是研究僧i 提交于 2020-01-16 04:17:11
问题 I am using Ruby on Rails 3.0.9 and I would like to know why I get the error described below and how can I solve that. In my /views/articles/categories/_content.html.erb file I have: ... <%= link_to("New article", {:controller => content[:article_controller], :action => 'new'}) %> ... If I set the content[:article_controller] to (both setting true and false for the :only_path option) 1. content[:article_controller] = 'articles' 2. content[:article_controller] = '/articles' 3. content[:article

php zend framework 2 routing with dynamic controller name but same controller

这一生的挚爱 提交于 2020-01-16 00:45:42
问题 i'm running into a routing beginners problem with zend framework 2: i want to make a routing that will work something like this: www.mysite.com/city/school/class with the routing i want to be able: www.mysite.com/chicago will take me to a city.phtml page with "chicago" as a parameter same with www.mysite.com/chicago/jcc will take me to a school.phtml with "jcc" as a parameter name and so on.. what i tried to do is: return array( 'router' => array( 'routes' => array( 'main' => array( 'type' =>

Optional Parameters While Routing angular2 [duplicate]

馋奶兔 提交于 2020-01-16 00:44:42
问题 This question already has answers here : Angular 2 optional route parameter (10 answers) Closed 3 years ago . How to define optional parameters in routing of angular2.my routing configuration like this: <a [routerLink]="['../abc',{xyz: blabla}]"> and <a [routerLink]="['../abc']"> { path: '/abc/:xyz', component: abc, name: 'abc' }, // Here i want xyz as optional perameter so the problem is whenever i am using first method with parameter blabla it works fine because at the time of routing i

Routing issues in .NET MVC [duplicate]

谁都会走 提交于 2020-01-15 12:36:42
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to get RouteData by URL? public override RouteData GetRouteData(HttpContextBase httpContext) { var url = httpContext.Request.Headers["HOST"]; var index = url.IndexOf("."); if (index < 0) return null; var subDomain = url.Substring(0, index); if (subDomain != "www" && subDomain != "m") { var routeData = new RouteData(this, new MvcRouteHandler()); routeData.Values.Add("controller", "Business"); routeData.Values

Running function again after route change in AngularJS

别来无恙 提交于 2020-01-15 10:56:10
问题 So I have a main controller and two others: calculatorApp.controller('companybController', function($scope, $http) { //define the hardware data $scope.customs.prodoc = 'companyb'; }); calculatorApp.controller('companyaController', function($scope, $http) { $scope.customs.prodoc = 'companya'; }); // create the controller and inject Angular's $scope calculatorApp.controller('mainController', function($scope, $http) { $scope.customs = { prodoc : '' }; }); But when switching routes - this works:

Alto Router not working for controllers

陌路散爱 提交于 2020-01-15 10:15:28
问题 I am trying pass controller name and method to Alto Router map method but it doesnt work in index.php i have following code <?php require_once 'vendor/autoload.php'; use Route\AltoRouter; use App\Controllers\HomeController; $router = new AltoRouter(); $router->setBasePath('demo/'); $router->map('GET','/', 'HomeController#index'); $router->map('GET', '/php', function(){ echo 'It is working'; }); $match = $router->match(); // call closure or throw 404 status if( $match && is_callable( $match[

Alto Router not working for controllers

。_饼干妹妹 提交于 2020-01-15 10:15:03
问题 I am trying pass controller name and method to Alto Router map method but it doesnt work in index.php i have following code <?php require_once 'vendor/autoload.php'; use Route\AltoRouter; use App\Controllers\HomeController; $router = new AltoRouter(); $router->setBasePath('demo/'); $router->map('GET','/', 'HomeController#index'); $router->map('GET', '/php', function(){ echo 'It is working'; }); $match = $router->match(); // call closure or throw 404 status if( $match && is_callable( $match[