angular-router

Angular how to get the non activated children routes

旧城冷巷雨未停 提交于 2021-02-19 03:38:06
问题 In Angular you can always inject ActivatedRoute in your component to get a reference to the current activated route. It has a property children which: Contains all the child routes activated under the current route. I was wondering how can I get all the children routes (so also the non activated ones). 回答1: You could use route.routeConfig.children to get the children defined in the router. 来源: https://stackoverflow.com/questions/46069944/angular-how-to-get-the-non-activated-children-routes

Why Angular 8 router is not working in Cordova IOS with WkWebView?

女生的网名这么多〃 提交于 2021-02-16 14:08:09
问题 I have an existing application built with Angular 8 and its code is shared by a website and 2 mobile applications for Android and IOS , bundled with the help of Cordova . It is working fine but Apple has announced that they will soon no longer supports apps built with UIWebView : The App Store will no longer accept new apps using UIWebView as of April 2020 and app updates using UIWebView as of December 2020. So I am forced to migrate it to WkWebView . There are several threads that I am aware

Why Angular 8 router is not working in Cordova IOS with WkWebView?

倖福魔咒の 提交于 2021-02-16 14:06:26
问题 I have an existing application built with Angular 8 and its code is shared by a website and 2 mobile applications for Android and IOS , bundled with the help of Cordova . It is working fine but Apple has announced that they will soon no longer supports apps built with UIWebView : The App Store will no longer accept new apps using UIWebView as of April 2020 and app updates using UIWebView as of December 2020. So I am forced to migrate it to WkWebView . There are several threads that I am aware

Angular 4 using a service in routing module

房东的猫 提交于 2021-02-07 13:24:34
问题 I'm trying to make a simple CMS system using a Laravel REST API. For the front-end i'm using the Angular 4 framework & angular CLI. Now i'm trying to generate dynamic routes (fetching pages from the API by using a service & generating routes for each of these pages). I tried this with a local data simulation and got this working like this. Routing.module.ts let cmsService: CmsService = new CmsService(); const pages = cmsService.getPageNames(); const routes: Routes = [ { path: '', component:

Is it possible to add redirect (301) inside angular app?

荒凉一梦 提交于 2021-01-29 12:58:14
问题 Let's say my app is running on domain.com and most of links in the internet to this site looks like this: domain.com/:id . I want to improve SEO a little bit and add redirects (301): domain.com/:id => domain.com/:title . But to get title for id I have to run angular app and check this in DB. So what I want to do is: User go to domain.com/:id Check title for id from url inside angular app Redirect user with 301 status to domain.com/:title 回答1: You have to run Angular using Angular Universal

Angular 2+ route resolvers not being called

匆匆过客 提交于 2021-01-28 06:10:27
问题 I have set up an AuthResolve class to ensure authentication is complete before displaying a route, but for some reason, the resolver is not getting called. neither the resolver function nor the constructor. The console does not log the logs I have inserted. I do not understand how this can be. Root level routes: export const appRoutes: Routes = [ { path: '', component: CallbackComponent, canActivate: [AuthGuardService], pathMatch: 'full', resolve: { auth: AuthResolve, }, }, { path: 'applicant

How to get id from the URL using snapshot or ActivatedRoute subscriber in Angular?

匆匆过客 提交于 2021-01-24 09:15:57
问题 I am getting value using snapshot method but it is getting the value after "classes" in this case 20 but I need 33 path like getting credits/33/classes/20 only 20 or credits/33/classes/ only null("") Update : I found a solution to my question. Now it is getting id properly. The mistake is accessing to element in the right child component, didn't work in child's MatDialog component within the Snapshot version. constructor(private route: ActivatedRoute) {} ngOnInit(): void { console.log

How to get id from the URL using snapshot or ActivatedRoute subscriber in Angular?

☆樱花仙子☆ 提交于 2021-01-24 09:14:09
问题 I am getting value using snapshot method but it is getting the value after "classes" in this case 20 but I need 33 path like getting credits/33/classes/20 only 20 or credits/33/classes/ only null("") Update : I found a solution to my question. Now it is getting id properly. The mistake is accessing to element in the right child component, didn't work in child's MatDialog component within the Snapshot version. constructor(private route: ActivatedRoute) {} ngOnInit(): void { console.log

Angular 8 test with Karma / Jasmine -> 100% code coverage not covered for loadChildren in angular routes

人走茶凉 提交于 2021-01-03 03:02:25
问题 After upgrading from angular 7 to 8, there were breaking changes in loadChildren for your application routes. When these are fixed and all test are running, i don't get a 100% code coverage (anymore), because the loadChildren isn't a 'string' anymore, but a LoadChildrenCallBack. How do i test this particulary part of code setup: import { NgModule } from '@angular/core'; import { RouterModule, RouterStateSnapshot, Routes } from '@angular/router'; import { RouterStateSerializer,

Angular 8 test with Karma / Jasmine -> 100% code coverage not covered for loadChildren in angular routes

混江龙づ霸主 提交于 2021-01-03 02:59:23
问题 After upgrading from angular 7 to 8, there were breaking changes in loadChildren for your application routes. When these are fixed and all test are running, i don't get a 100% code coverage (anymore), because the loadChildren isn't a 'string' anymore, but a LoadChildrenCallBack. How do i test this particulary part of code setup: import { NgModule } from '@angular/core'; import { RouterModule, RouterStateSnapshot, Routes } from '@angular/router'; import { RouterStateSerializer,