angular

Angular Effects - how to get 100 percent test result (coverage in funcs )?

亡梦爱人 提交于 2021-02-11 13:40:51
问题 here is my effects: import { Injectable } from '@angular/core'; import { Action } from '@ngrx/store'; import { Actions, createEffect, ofType } from '@ngrx/effects'; import { of, Observable } from 'rxjs'; import { catchError, map, switchMap } from 'rxjs/operators'; import * as courseAttributeActions from '../actions/candidate-registration-management.action'; import { CandidateRegistrationManagementService } from '../../services/candidate-registration-management.service'; @Injectable() export

I want to call Token API from Microsoft graph in angular 7+ http call

久未见 提交于 2021-02-11 13:39:40
问题 From angular application i want to call https://login.microsoftonline.com/##tenant##/oauth2/v2.0/token api to get access token from http call and using that token i want to call https://graph.microsoft.com/v1.0/users/##UserId##​​​​​​​​​​​​​/getMemberGroups API without using any npm package of angular. I tried using http service, but getting below error Access to XMLHttpRequest at 'https://login.microsoftonline.com/xxxx/oauth2/v2.0/token' from origin 'https://xxx.co' has been blocked by CORS

Angular: What's the correct way to return Observable?

萝らか妹 提交于 2021-02-11 13:38:33
问题 I have the following method which isn't working correct: getProducts(): Observable<Product[]> { let PRODUCTS: Product[]; this.http.get(this.base_url + "api/products") .subscribe( (data) => { for(var i in data) { PRODUCTS.push(new Product(data[i].id, data[i].name, data[i].category, data[i].description, data[i].price, data[i].amount)); } }, (error) => { console.log(error); }); return of(PRODUCTS); } The error I'm getting is this: TypeError: Cannot read property 'push' of undefined Now, I know

Angular 8 beforeunload event event not work on close tab

岁酱吖の 提交于 2021-02-11 13:35:34
问题 Hey i try to make http request on close tab but its not work, But if i navigate to other component its work. I try to change the function like this post Angular 2 - Execute code when closing window But its now work for me. My http service: removeCurrentEditor(reportID) { return this.http.request('GET', this.baseUrl + this.REPORTS_API + '/' + this.REMOVE_CURRENT_EDITOR + '/' + reportID, {responseType: 'json'}); } my component: // Handle close tab @HostListener('window:beforeunload', ['$event']

Export xlsx to csv in Angular

时间秒杀一切 提交于 2021-02-11 13:27:14
问题 I am using XLSX to parse data from an xlsx file. The problem is that when I try to get the data, the data is different depending on whether I read it in XLSX and CSV. I prefer to read it in CSV, since if I don't have to transform the dates according to the Excel format. I am trying to convert the XLSX file to CSV when the user uploads the file. The way I try is: const reader: FileReader = new FileReader(); reader.onload = (e: any) => { var binaryData = e.target.result; //Converting Binary

Export xlsx to csv in Angular

╄→гoц情女王★ 提交于 2021-02-11 13:25:08
问题 I am using XLSX to parse data from an xlsx file. The problem is that when I try to get the data, the data is different depending on whether I read it in XLSX and CSV. I prefer to read it in CSV, since if I don't have to transform the dates according to the Excel format. I am trying to convert the XLSX file to CSV when the user uploads the file. The way I try is: const reader: FileReader = new FileReader(); reader.onload = (e: any) => { var binaryData = e.target.result; //Converting Binary

How to set individual option list for selects in a formbuilder

只愿长相守 提交于 2021-02-11 13:25:00
问题 I have a model driven form with 2 selects, 'State' and 'City'. The models looks something as below : class State{ stateID : number; stateName : String, cities : City[] } class City{ cityID : number, cityName : String } I am populating the city option list from the selection of state as I have all the data available in State[] 'stateList'. <select formControlName="state" (onchange)="getCityNameByState($event.target.value)"> <option *ngFor="let stateName of stateList" [value]= "stateID"> {

How to use PathLocationStrategy on localhost?

六月ゝ 毕业季﹏ 提交于 2021-02-11 13:21:14
问题 I'm working on an Angular 4 web app and I need to use PathLocationStrategy (not HashLocationStrategy ). The only problem with PathLocationStrategy is that when I refresh a page, I instantly get a blank page with 404 errors in the console... Which is normal with PathLocationStrategy . Once on a server, I can fix that by redirecting the routes to point on index.html. But how to fix this issue on localhost when I launch my app with ng serve ? It would be ideal since I'm working in "livereload",

Angular 10 SSR and expressjs sessions

前提是你 提交于 2021-02-11 13:09:05
问题 I have a component in Angular where I'm using HttpClient to do a GET request to the server to get the currently signed in user. Since this is an SSR app the code runs both on the client and the server. The problem is that when it runs on the server, the session data is not available, which means that the request to the backend can't be authenticated, so it fails. On the client the session data is available so the request succeeds. I use express-session with the following session options:

Need to pause the Carousel animation regularly and call a function

痴心易碎 提交于 2021-02-11 12:51:45
问题 I have a Carousel animation: which is working fine but I need to pause it after a duration and call a function. As soon as the cards change their position, I want to pause it, call my function, and as soon as the execution of that function is over, again restart the animation. And I want to do this indefinitely. I am creating my animation using AnimationBuilder 's build() function. I tried to make use of AnimationPlayer 's pause() and restart() methods but was not able to set them properly.