angular4-router

Angular routing doesn't work after deploy into a Springboot Application

冷暖自知 提交于 2019-12-11 00:56:27
问题 I have build a Springboot Application including Angluar5. I have a gradle build script which loads the angular files into my springboot project.The files are under resources/static of my springboot project. When i start my application the routing of angular is not working anymore and i get Error: Cannot match any routes. URL Segment: 'access' My project structure: I deployed my angular app with following statement: ng build --deploy-url=BeatAcknowledgeTest --op=../backend/src/main/resources

How to integrate angular with spring boot to see angular web interface on spring boot port?

孤街醉人 提交于 2019-12-10 10:48:06
问题 I have backend spring boot app and front-end developed using angular4. Since these 2 operate on different ports(8080,4200) when deploying, it isn't showing any UI. In local, starting angular server using below works absolutely fine on localhost:4200 and shows web interface: ng serve --proxy-config proxy.conf.json where proxy.conf.json has contents: { "*": { "target": "http://localhost:8080", "secure": false, "logLevel": "debug" } } But not when trying to integrate with springboot app

Get router params from another component in Angular

不想你离开。 提交于 2019-12-08 13:26:52
问题 I'm using Angular4. I have some BarComponent that displays in the app.component template (for almost all pages, it's like menu bar). I want to get the router params that "belongs" to another component, not a children/child of the BarComponent. For example, I have the route: /some-section-name/:id{here may be sub-routes} Can I get this :id param using the Angular methods within the BarComponent? Structure is like: |- app.component |- bar.component |- (lazy load) some section |- here is the

Getting Can't bind to 'routerLink' since it isn't a known property of 'a'. error in spite of referencing router moudule

喜欢而已 提交于 2019-12-07 04:48:30
问题 I am implementing basic routing in my angular 4 application and getting the following error when loading the application on the browser. I have defined the routes in approuting.module as also referenced the router module in Ngmodule as well approuting.module. Not sure what the problem is Can't bind to 'routerLink' since it isn't a known property of 'a'. Can't bind to 'routerLink' since it isn't a known property of 'a'. ("ew" [hidden]="!dataItem.isVisibleView"> <a [ERROR ->][routerLink]="['

Autosave the form/model content on route change in angular 4

▼魔方 西西 提交于 2019-12-06 07:14:01
问题 In angular 4 application, I am moving from one module to other I want to save my content automatically so I need to identify the change in route. class MyClass { constructor(private router: Router) { router.events.subscribe((val) => { // see also console.log(val instanceof NavigationEnd) }); } } I have used this code but this call is incrementing for every visit. Its similar to Gmail compose how it saves data to draft when I moved from composing screen to other. 回答1: You are leaving the

how to alert user on click of browser back button in angular 4?

岁酱吖の 提交于 2019-12-06 06:43:04
how to alert the user on click of browser back button in angular 4? onpopstate gets called even when the page loads for the first time import { PlatformLocation } from '@angular/common'; constructor( private platformLocation: PlatformLocation) { platformLocation.onPopState(() => { console.log("onPopState called"); window.alert("your data will be lost"); }) } Add a candeactivate guard can-deactivate-guard.service.ts import {Observable} from 'rxjs'; import {CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router'; export interface CanComponentDeactivate { canDeactivate:

How to integrate angular with spring boot to see angular web interface on spring boot port?

风流意气都作罢 提交于 2019-12-06 05:16:07
I have backend spring boot app and front-end developed using angular4. Since these 2 operate on different ports(8080,4200) when deploying, it isn't showing any UI. In local, starting angular server using below works absolutely fine on localhost:4200 and shows web interface: ng serve --proxy-config proxy.conf.json where proxy.conf.json has contents: { "*": { "target": "http://localhost:8080", "secure": false, "logLevel": "debug" } } But not when trying to integrate with springboot app(localhost:8080). Probably, it requires ng business logic(node/npm install etc.) to be baked before deployment.

angular 4 router without router-outlet

ぐ巨炮叔叔 提交于 2019-12-04 10:08:21
I am currently implementing a custom state management in angular 4 based on angular router, basically without any router-outlet attaching and detaching components myself based on routing events. It works fine until i try to navigate from a route with parameters to the same route with different parameters, then it crashes. This plunkr ( watch the console ) explains my situation. Navigating from ' crisis center ' to ' heroes ' is fine, navigating from ' heroes ' to ' hero 11 ' is fine, navigating from ' hero11 ' to ' hero12 ' throws the error TypeError: Cannot read property 'component' of null I

Angular 4 router: prevent direct browser navigation

≯℡__Kan透↙ 提交于 2019-12-04 04:34:34
How can I convince the Angular 4 router to disable direct browser navigation within my app? I have looked into the router hooks CanActivate and CanDeactivate and implemented them but CanDeactivate does not fire at all when using direct browser navigation. I can use CanActivate to prevent the url but only after the app reboots, which takes time and undesired changes in the browser window. I want to be able to catch the direct browser navigation BEFORE the app reboots. In case this helps: I want to disallow direct browser navigation altogether, so I don't need a solution that allows certain urls

Router named outlets that are activated once

∥☆過路亽.° 提交于 2019-12-04 03:01:35
问题 Is it possible to have router named outlets that are activated once and then never destroyed, no matter what route is navigated in primary outlet? The intention is to have components that persist on page (for instance, sidebar ) but get the benefits of routing on their initial load - such as guards (resolvers) and lazy loading. The requirement is that named outlets shouldn't affect UX in any negative way, for example by introducing garbage suffixes to SPA URL, e.g. (outletName:routeName) ,