angular

Typescript: Use class as interface

雨燕双飞 提交于 2021-02-17 19:01:07
问题 I tried to use an Class as Interface for another class. With this I am trying to accomplish an up-to-date mockClass for Testing. This should be possible and is an favorable approach, as state in https://angular.io/guide/styleguide#interfaces And is demonstrate here: Export class as interface in Angular2 But strangely I'm getting an Error using Typescript 2.5.3 in VSCode 1.17.2 Error in class SpecialTest [ts] Class 'SpecialTest' incorrectly implements interface 'Test'. Types have separate

How can I get children elements from QueryList in Angular 2?

故事扮演 提交于 2021-02-17 15:16:27
问题 I am newbie at Angular2. In my view I have few identical children that are generated in *ngFor. <ngb-panel *ngFor="let client of clients" [title]="'Client #' + client.id"> <template ngbPanelContent> <processing-item [client]="client"></processing-item> </template> </ngb-panel> I need to call methods of these components at parent element and find out the ViewChildren decorator and the code is: @ViewChildren(ProcessingItemComponent) processingItems: QueryList<ProcessingItemComponent>; Then I

How can I get children elements from QueryList in Angular 2?

不想你离开。 提交于 2021-02-17 15:14:38
问题 I am newbie at Angular2. In my view I have few identical children that are generated in *ngFor. <ngb-panel *ngFor="let client of clients" [title]="'Client #' + client.id"> <template ngbPanelContent> <processing-item [client]="client"></processing-item> </template> </ngb-panel> I need to call methods of these components at parent element and find out the ViewChildren decorator and the code is: @ViewChildren(ProcessingItemComponent) processingItems: QueryList<ProcessingItemComponent>; Then I

issue with flask-cors - blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status

☆樱花仙子☆ 提交于 2021-02-17 07:17:31
问题 I'm a newbie in flask and angular please bear with me. I've been stuck with an issue about CORS. I've applied different code fixes just to make it work. Now the error that I am getting is Access to XMLHttpRequest at 'http://localhost:5000/dashboard/clientscount/2019/2020' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status. I think the answer to my problem is from the answered

Can we change root APIURL in angular 8 without building project with environment development or production from CLI

馋奶兔 提交于 2021-02-17 05:48:13
问题 Do we need to build project two times with prod and development, or is there any other way to change the root URL of API pointed on different server and root url change without building the project. 回答1: We can create a config.json file in project directory and in app.component.ts read the new configuration setting without rebuilding the project. I got solution here https://github.com/angular/angular-cli/issues/12442 回答2: I don't understand why a lot of people keep their API URL root in

Error when compiling Universal Angular with ngx-translate

ε祈祈猫儿з 提交于 2021-02-17 05:45:12
问题 I am configuring ngx-translate as follows: translate-server-loader.service.ts import {Observable} from "rxjs/Observable"; import {TranslateLoader} from '@ngx-translate/core'; import { Injectable } from '@angular/core'; import {makeStateKey, StateKey, TransferState} from '@angular/platform-browser'; import {TranslateHttpLoader} from '@ngx-translate/http-loader'; import {HttpClient} from '@angular/common/http'; @Injectable() export class TranslateBrowserLoader implements TranslateLoader {

How to set initial value in dropdown in angular8

别等时光非礼了梦想. 提交于 2021-02-17 05:39:05
问题 I have two items in dropdown. I need to set initial value as first value from array below is my code objects = ['production', 'development']; this.object = this.objects[0]; <div class="item"> <select formControlName="db" class="form-control" (change)="changeDb($event)" [ngModel]="object"> <option *ngFor="let object of objects" [ngValue]="object">{{object}}</option> </select> </div> The value is not setting using above code.It is showing in ng reflect model but not in UI 回答1: You can add an

How to make icon change only for particular table instead of changing as whole

天涯浪子 提交于 2021-02-17 04:39:24
问题 Hi I have multiple tables looped in an array, but here if i click on icon of first table, the icon in that header name of all the tables are getting changed instead of changing to particular table. DEMO: DEMO TS: public sortContactsList(param,key) { this.sorting = (this.sorting === 'asc') ? 'desc' : 'asc'; this.contactListDetails.forEach(item => { if (item.param === param) { item.icon = item.icon === 'fa fa-sort-down active' ? 'fa fa-sort-up active' : 'fa fa-sort-down active'; this.sorting =

How to make icon change only for particular table instead of changing as whole

情到浓时终转凉″ 提交于 2021-02-17 04:39:07
问题 Hi I have multiple tables looped in an array, but here if i click on icon of first table, the icon in that header name of all the tables are getting changed instead of changing to particular table. DEMO: DEMO TS: public sortContactsList(param,key) { this.sorting = (this.sorting === 'asc') ? 'desc' : 'asc'; this.contactListDetails.forEach(item => { if (item.param === param) { item.icon = item.icon === 'fa fa-sort-down active' ? 'fa fa-sort-up active' : 'fa fa-sort-down active'; this.sorting =

Ngrx effect parallel http call

这一生的挚爱 提交于 2021-02-17 02:09:14
问题 I have an effect that should call two different APIs (API1 and API2). Here's the effect $LoadKpiMission = createEffect(() => this.actions$.pipe( ofType<any>(EKpiActions.GetMissionsByStation), mergeMap(action => this.apiCallsService.getKpi(action.payload, '2016-04-18').pipe( map(trips => ({ type: EKpiActions.GetMissionsSuccess, payload: trips })), catchError(() => EMPTY) ) ) ) ); Here's the structure of the service getKpi(station: number, date: string) { let Kpi = `http://192.168.208.25:8998