angular

Angular 6 httpClient Post with credentials

时光总嘲笑我的痴心妄想 提交于 2021-02-18 06:40:06
问题 I have some code which posts some data to create a data record. It's in a service: Here's the code: import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) }; @Injectable({ providedIn: 'root' }) export class ApiService { constructor(private http: HttpClient) { } create() { const postedData = { userid: 1, title: 'title here', body: 'body text' }; return

Angular 4 - canActivate observable not invoked

眉间皱痕 提交于 2021-02-18 06:29:13
问题 I am trying to implement canActivate in Angular 2/4 using RxJS observables. I have already read another SO question on this. With the following code, my canActivate method works only once, when the app launches, but hello is never printed again when the isLoggedIn observable triggers new values. canActivate(): Observable<boolean> { return this.authService.isLoggedIn().map(isLoggedIn => { console.log('hello'); if (!isLoggedIn) { this.router.navigate(['/login']); } return isLoggedIn; }).first()

Angular 4 - canActivate observable not invoked

二次信任 提交于 2021-02-18 06:27:47
问题 I am trying to implement canActivate in Angular 2/4 using RxJS observables. I have already read another SO question on this. With the following code, my canActivate method works only once, when the app launches, but hello is never printed again when the isLoggedIn observable triggers new values. canActivate(): Observable<boolean> { return this.authService.isLoggedIn().map(isLoggedIn => { console.log('hello'); if (!isLoggedIn) { this.router.navigate(['/login']); } return isLoggedIn; }).first()

Angular: Run canActivate on each route change

笑着哭i 提交于 2021-02-18 06:09:06
问题 I got stuck recently with Angular route guards. CanActive runs only once when the page is loaded and does not run on route change within the guarded route. I think this was changed because it used to run on each change. From what I read in forums, I should use CanActivateChild. The thing is, our application consists of several modules, that have several route descendants and when I use CanActivateChild in root module, it is called several times when changing the route. I find it dumb to

Angular: Run canActivate on each route change

送分小仙女□ 提交于 2021-02-18 06:06:11
问题 I got stuck recently with Angular route guards. CanActive runs only once when the page is loaded and does not run on route change within the guarded route. I think this was changed because it used to run on each change. From what I read in forums, I should use CanActivateChild. The thing is, our application consists of several modules, that have several route descendants and when I use CanActivateChild in root module, it is called several times when changing the route. I find it dumb to

what is the difference between event binding and property binding?

烈酒焚心 提交于 2021-02-17 21:54:12
问题 In the architecture of angular 2 there are two terms Event binding and Property binding. What is the difference between them? 回答1: Property binding - In case you have to pass the value from parent component to child component (whether the value is static or dynamic) we have to use the property binding that mean by doing so we send the value using attribute on component and receive it in the child component by using @Input decorator for example of property binding see here - <my-child [myProp]

what is the difference between event binding and property binding?

狂风中的少年 提交于 2021-02-17 21:53:45
问题 In the architecture of angular 2 there are two terms Event binding and Property binding. What is the difference between them? 回答1: Property binding - In case you have to pass the value from parent component to child component (whether the value is static or dynamic) we have to use the property binding that mean by doing so we send the value using attribute on component and receive it in the child component by using @Input decorator for example of property binding see here - <my-child [myProp]

Angular 6 ag-grid cell renderer click function

Deadly 提交于 2021-02-17 21:19:26
问题 So I'm trying to setup ag-grid and I can't get one thing to work. I want to have a column that is actions. Then I want it to have a link or button that triggers a method in the component file. For the column def I have the following. What am I doing wrong? { headerName: 'Actions', cellRenderer: params => { return `<a (click)="onEditClick("${params.data.hostname}")">Edit</a>`; } } 回答1: I use cellRenderFramework: { headerName: '', width: 30, cellRendererFramework: ActionCellRendererComponent,

IdentityServer External auth provider - auth-callback - Redirection - 400 Bad request

爷,独闯天下 提交于 2021-02-17 19:20:50
问题 I am following https://www.scottbrady91.com/Angular/SPA-Authentiction-using-OpenID-Connect-Angular-CLI-and-oidc-client and https://www.scottbrady91.com/Angular/Migrating-oidc-client-js-to-use-the-OpenID-Connect-Authorization-Code-Flow-and-PKCE to implement OIDC in SPA(Angular) I am using aspboilerplate integrated IdentityServer I've set up everything as per the above articles and I was able to navigate to external auth provider and was also able to enter the required credentials. While

IdentityServer External auth provider - auth-callback - Redirection - 400 Bad request

让人想犯罪 __ 提交于 2021-02-17 19:20:29
问题 I am following https://www.scottbrady91.com/Angular/SPA-Authentiction-using-OpenID-Connect-Angular-CLI-and-oidc-client and https://www.scottbrady91.com/Angular/Migrating-oidc-client-js-to-use-the-OpenID-Connect-Authorization-Code-Flow-and-PKCE to implement OIDC in SPA(Angular) I am using aspboilerplate integrated IdentityServer I've set up everything as per the above articles and I was able to navigate to external auth provider and was also able to enter the required credentials. While