angular-routing

Why this is not loading view1.cshtml in MVC empty web application ANGULAR

人盡茶涼 提交于 2019-12-23 06:12:23
问题 I am learning Angular. I am watching a 2 years old video, and I am trying to use route concept and using in view1.CShtml (Remember, its CShtml and not html, while in the video, he uses html). I also find it wierd that Views path starts as ~Views/View1.cshtml (Fair enough I have it in Views folder) on contrary to Partial/View1 where the video demonstrator has. Now, I do not understand what is this "~" for when I have similar directory structure like demonstrator. Also, sadly, the view1 is not

Angular lazyload child routes with outlet

风格不统一 提交于 2019-12-23 03:43:08
问题 I have tried to reproduce my error in a stackblitz What I try to accomplish I am trying to have a route with a dynamic parameter, and have sub routes of that parameter. I want this module to be lazyloaded. I have made a working solution for the dynamic parameter using the :id definition in the route definition. I want the child routes to output in a different router-outlet. Specifically I want a component ( UserComponent ) loaded on the route user/:username - if the path is empty after the

Angular: setting baseHref does not create subfolders

ε祈祈猫儿з 提交于 2019-12-23 03:37:18
问题 When you run ng build with --base-href "/some/path/" , why does angular not create subdirectories according to the path? When I start a http-server in my /dist/ I get errors like GET /some/path/assets/images/image.png Not Found! thrown in my face. when you look into /dist/ , the problem is clear: there is only the assets folder directly, not inside other folders. So what is the right way to set a baseHref? What I try to accomplish is having different versions of the app (with different i18n

Angular: Some routes use PathLocationStrategy but some other routes use HashLocationStrategy

ぐ巨炮叔叔 提交于 2019-12-23 02:25:08
问题 I have 4 routes in my app.routes. import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; export const pageRoutes: Routes = [ {path: '', redirectTo: 'home', pathMatch: 'full'}, {path: 'home', component: HomeComponent}, {path: 'transaction', loadChildren: './app/transaction.module#TransactionModule'}, {path: 'evidence', loadChildren: './app/evidence.module#EvidenceModule'} ]; @NgModule({ imports: [RouterModule.forRoot(pageRoutes)], exports:

How to correctly implement multiple views with UI Router in Angular?

情到浓时终转凉″ 提交于 2019-12-23 02:10:22
问题 I'm trying to implement a site with two main content 'panes' (imagine two columns each half the width of the page). The panes should be able to change independent of each other and have their own controllers and be able to pass data between each other (so the user can navigate through a bunch of pages on the left pane while the right pane stays the same without reloading and vice versa, and a change in the left pane can update data showing up in the right pane). I've looked through a bunch of

Passing multiple parameters in an AngularJS route

风流意气都作罢 提交于 2019-12-22 06:25:18
问题 I am trying to implement a angular route which should have multiple parameters. Here is an example of what I tried: .when('/myRoute/paramA/:paramA/paramB/:paramB/paramC/:paramC', { templateUrl: 'abc.html', controller: 'pwrController as pwrCtrl' }); Now the problem in this is that I need to always pass paramA in order to pass paramB. And paramA and paramB in order to pass paramC. Is there any way in angular where I can pass paramA, paramB or paramC independently ? Thanks. ! 回答1: inject

Passing multiple parameters in an AngularJS route

你。 提交于 2019-12-22 06:25:09
问题 I am trying to implement a angular route which should have multiple parameters. Here is an example of what I tried: .when('/myRoute/paramA/:paramA/paramB/:paramB/paramC/:paramC', { templateUrl: 'abc.html', controller: 'pwrController as pwrCtrl' }); Now the problem in this is that I need to always pass paramA in order to pass paramB. And paramA and paramB in order to pass paramC. Is there any way in angular where I can pass paramA, paramB or paramC independently ? Thanks. ! 回答1: inject

Angular.js - getting access to the params via $route or $routeParams

最后都变了- 提交于 2019-12-22 04:55:40
问题 I have an Controller in which I inject $route and $routeParams but when I go to get the value via $route.routes.current.params.test ->> current is undefined $routeParams.test ->> test is undefined Both objects seem to be populated correctly when I use console.log($route) or console.log($routeParams) I'm baffled. How could the value be there for console.log but fail inside the same controller that I doing the console.log from? Update: Sample Code angular.module('TestApp') .controller(

Angular2+ routeReuseStrategy lifecycle hooks

爷,独闯天下 提交于 2019-12-21 11:27:18
问题 I'm trying to take advantage of a custom RouteReuseStrategy and for that I'd like to suspend any subscriptions when a component is detached and other things like scrolling to the proper position. I've checked for possible hooks, but apparently no additional lifecycle hooks have been added and OnDestroy isn't called. I tried to add my own onDetach and onAttach hooks, but neither the ActivatedRouteSnapshots nor the DetachedRouteHandle will give me the instance of the current component (just the

How to provide a service that uses generics in Angular4?

女生的网名这么多〃 提交于 2019-12-21 04:17:19
问题 I notice that my project has a lot of resolver services that despite from working with different entities and repositories host the same code. So I took the challenge to reduce them to a single resolver service using generics: @Injectable() export class DetailResolver<T, R extends Repository<T>> implements Resolve<T> { constructor(private repositoryService: R, private router: Router) {} resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<T> { // use