angular-routing

Routing to static html page in Angular 6+

被刻印的时光 ゝ 提交于 2020-03-17 08:59:11
问题 I have an Angular project with 3 components country, region, home. When I load the home page, I have route setup to HomeComponent , which hyperlinks for routes. Everything works just fine and behaving like a single page (SPA). Now, I want to add a static HTML page and route to it. I looked at Angular Route documentation, I couldn't find a way to do this. Here are the questions I have Where can I place my static HTML pages How to route those file in app-routing.module.ts Github Repository:

How to refresh element in angular 8 without page reload?

这一生的挚爱 提交于 2020-02-25 13:28:46
问题 i'm updating database column with a button click, and i want to change the button after click. How can i achieve that without refreshing the page? Below is my code. and it works fine only if i refresh the page. <button *ngIf="solved==1" class="btn btn-success float-right">Marked</button> <button *ngIf="solved==0" (click)="mark()" class="btn btn-warning float-right">Mark </button> 回答1: You can call the ngOnInit() once you are done with the processing logic of mark() mark() { ... this.ngOnInit(

How to refresh element in angular 8 without page reload?

会有一股神秘感。 提交于 2020-02-25 13:28:25
问题 i'm updating database column with a button click, and i want to change the button after click. How can i achieve that without refreshing the page? Below is my code. and it works fine only if i refresh the page. <button *ngIf="solved==1" class="btn btn-success float-right">Marked</button> <button *ngIf="solved==0" (click)="mark()" class="btn btn-warning float-right">Mark </button> 回答1: You can call the ngOnInit() once you are done with the processing logic of mark() mark() { ... this.ngOnInit(

How to disable url changes with Angular routing

扶醉桌前 提交于 2020-02-22 10:57:15
问题 My Angular 7 app needs to be rendered in an iFrame. Due to the peculiar nature of the system, I need to prevent the URL from changing, or maybe I should say that I need Angular not to expect the URL to change. I've found posts that show how to prevent it on specific routing calls, but the URL is updated when the app loads too. The objective is to maintain the URL like: website.com/applicaition, even when the route changes such that there is no update to the window.location. https://website

Angular2 Router: add hashtag to url

谁都会走 提交于 2020-02-02 06:29:28
问题 I'm using Angular2 Seed application, and you can find it in the official repo. As you can see, here we have angular2/router imported, and we're using it to create the basic routing of the application. import {Component, ViewEncapsulation} from 'angular2/angular2'; import { RouteConfig, ROUTER_DIRECTIVES } from 'angular2/router'; ... @RouteConfig([ { path: '/', component: HomeCmp, as: 'Home' }, { path: '/about', component: AboutCmp, as: 'About' } ]) export class AppCmp {} My question is: how

Angular application not loading with parameters when reloading with IIS URL Rewrite

感情迁移 提交于 2020-01-30 11:57:26
问题 I have an Angular 8 application configured in my local IIS. I have also installed and configured IIS URL Rewrite. The issue is that the application is loading fine if I access it from the start page. But if at any instance, I reload the application or if I try to access the inner pages using the URL, I get the following error. Please find my IIS URL Rewrite config below : <configuration> <system.webServer> <rewrite> <rules> <rule name="AngularJS Routes" stopProcessing="true"> <match url=".*"

Angular: How to get component instance of router-outlet

人盡茶涼 提交于 2020-01-30 04:28:10
问题 html: <router-outlet></router-outlet> component: @Component({ selector: 'xx', templateUrl: './xx.html', styleUrls: ['./xx.css'], providers: [ RouterOutlet] }) export class AppComponent { constructor(private routeroutlet: RouterOutlet){ } getref() { console.log(this.routeroutlet); console.log('refresh', this.routeroutlet.component); } } i'm getting this error core.es5.js:1224 ERROR Error: Outlet is not activated at RouterOutlet.get [as component] (router.es5.js:5449) at AppComponent

Angular 5, using a component in a sub-module

北慕城南 提交于 2020-01-24 13:52:26
问题 I am getting an error I cannot seem to remedy, when I sub-divided my app for lazy loading efficiencies and and using a sub-router for "child" , I need to use a component that is used in the main app. But I am getting This below error message Type AccountInfoComponent is part of the declarations of 2 modules My app structure looks like this app |--components |--accountInfo |--accountInfo.component.ts |--user |--user.component.ts |--modules |--child |--child.component.ts |--child.module.ts |-

How to get the previous page URL in angular 5

随声附和 提交于 2020-01-24 11:16:12
问题 I'm working with Angular 5 app and I need to know how to get the last URL to place it as a link to my back button. I found this location.back() but what I need the last url as a string. How could I get the string that generates location.back() ? Many Thanks! 回答1: Angular 6 updated code for getting previous url as string. import { Component, OnInit } from '@angular/core'; import { Router, RoutesRecognized } from '@angular/router'; import { filter, pairwise } from 'rxjs/operators'; export class

Routing to sub routing module without lazy loading

吃可爱长大的小学妹 提交于 2020-01-23 05:42:05
问题 I want to have multiple routing modules in order to keep my application clean and easy to read. I currently use lazy loading for the SubComponent but I don't want to do this. So I am looking for a way to change this. Anyways, here is the currently working code. I have the following two routing files. app-routing.module.ts : import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; const routes: Routes = [ { path: '', component: HomeComponent }, { path: