routes

Route to different View(use @Html.ActionLink and ng-view in View) in Asp.Net MVC with AngularJS, ng-view only work one time, location url strange

非 Y 不嫁゛ 提交于 2019-11-30 16:18:58
问题 In my case, I need use @Html.ActionLink to Route to different View with AngularJS.In each view1/index.cshtml in asp.net has <div ng-view></div> that will load its html template. the following link image is my project structure: click My problem is: it only route success first time.I think it cause wrong location url. Views/Share/_Layout.cshtml: <ul> <li>@Html.ActionLink("Home", "Index", "Home")</li> <li>@Html.ActionLink("Device Management", "Index", "DeviceManagement")</li> </ul> Views/Home

Generate a URL From Route Data ONLY

不打扰是莪最后的温柔 提交于 2019-11-30 15:57:29
I'm trying to do something simple in ASP.NET MVC: RouteValuesDictionary routeValues = GetMyRouteData(); var url = new UrlHelper(Html.ViewContext.RequestContext); return url.RouteUrl(routeValues); The problem is that no matter what I do, the url includes route data from the current request context. I want to generate a URL based on ONLY the route values from GetMyRouteData() . Thanks Darin Dimitrov The problem is that no matter what I do, the url includes route data from the current request context That's by design. You have to explicitly set the route values that were present in the original

How to router.navigate to same route in Angular 4 and catch the same event?

▼魔方 西西 提交于 2019-11-30 14:34:52
Okay, I have two use cases for my question here: I'm working on an application which has a /en/register route. It all works good when I'm at the root and I click a button that does this.router.navigate([this.routeParams.lang, 'register']); and it's all good, this opens up a modal in the constructor (or ngOnInit, anyways) with ($('#modalRegister') as any).modal('show'); . It all works good, but if I close the modal, the route is still /en/register/ (yeah I can make it go to /en but see the use case #2 before you suggest this), so when I click the button, it doesn't do anything. Neither the

Angular 7+: HMR (Hot Module Replacement) does not work if any route-resolve involved

爱⌒轻易说出口 提交于 2019-11-30 13:51:55
HMR (Hot Module Replacement) is a great functionality, that works properly if no "Route-resolve" (see below) is present. If I remove resolve here: { path: 'new', component: BookNewComponent, data: { breadcrumb: 'book.new.breadcrumb' }, resolve: { staticData: StaticDataResolve } }, HMR is working again. If resolve exists -> HMR reloads the whole app instead of a specific component. How can I solve this problem? 来源: https://stackoverflow.com/questions/55355133/angular-7-hmr-hot-module-replacement-does-not-work-if-any-route-resolve-invo

Middleware, how to redirect after check Laravel 5

你。 提交于 2019-11-30 13:35:50
I need after check if user is logged as editor, to redirect to profile page... Here is my code: <?php namespace App\Http\Middleware; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Redirect; use Closure; class AdminMiddleware { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if(Auth::check()){ if(Auth::user()->roles->toArray()[0]['role'] == 'editor'){ return redirect('/profile'); } return $next($request); } else { return $next($request); } } } Problem

rails devise, no route matches logout

旧巷老猫 提交于 2019-11-30 12:09:59
Though there're lots of similar questions, i've searched for it for hours but still can not fix it. Env rails 3.0.9 ruby 1.9.2 devise 1.4.2 I changed the default login url using: 5 resources :users 6 devise_for :users, :path => "", :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification', :unlock => 'unblock', :registration => 'register', :sign_up => 'cmon_let_me_in' } And the http://localhost:3000/login works fine for me But I include = link_to 'sign_out', destroy_user_session_path, :method => :delete in my application.haml, after i

Finding the number of paths of given length in a undirected unweighted graph

大憨熊 提交于 2019-11-30 12:07:42
问题 'Length' of a path is the number of edges in the path. Given a source and a destination vertex, I want to find the number of paths form the source vertex to the destination vertex of given length k. We can visit each vertex as many times as we want, so if a path from a to b goes like this: a -> c -> b -> c -> b it is considered valid. This means there can be cycles and we can go through the destination more than once. Two vertices can be connected by more than one edge. So if vertex a an

How to write controller tests when you override devise registration controller?

左心房为你撑大大i 提交于 2019-11-30 11:49:52
问题 I wish to override the Devise::RegistrationsController to implement some custom functionalality. To do this, I've created a new RegistrationsController like so: # /app/controllers/registrations_controller.rb class RegistrationsController < Devise::RegistrationsController def new super end end and set up my routes like this: devise_for :users, :controllers => { :registrations => "registrations" } and tried to test it like this: describe RegistrationsController do describe "GET 'new'" do it

Zend Framework 2: get matched route in view

半世苍凉 提交于 2019-11-30 11:47:06
I'm currently learning ZF2 by developing a small MVC application roughly based on the skeleton app. Right now I'm trying to hide some fixed HTML elements based on the route matched: just as an example, I don't want the main menu to show during the login phase. I can do that easily by passing toggle parameters as return values from the controller actions, but it doesn't feel right, so I'd like to just check the matched route from the layout and compose the layout accordingly. Problem is, I don't know how to get the matched route in the template. Is this possible? Are there other solutions to

Rails: form_for namespaced resource

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 11:31:37
I want to set up the CRUD for users, available just for administrators of my web application. So in routes.rb: namespace :admin do resources :user end which means this: admin_user_index GET /admin/user(.:format) admin/user#index POST /admin/user(.:format) admin/user#create new_admin_user GET /admin/user/new(.:format) admin/user#new edit_admin_user GET /admin/user/:id/edit(.:format) admin/user#edit admin_user GET /admin/user/:id(.:format) admin/user#show PUT /admin/user/:id(.:format) admin/user#update DELETE /admin/user/:id(.:format) admin/user#destroy Show, index work fine but edit and new don