angular

Type 'Observable<HttpEvent<>>' is not assignable to type 'Observable<>'

半腔热情 提交于 2021-02-08 15:10:35
问题 I have this code snippet: SubmitTransaction(transNumber: string, transactionRequest: ITransactionRequestObj): Observable<TransactionResponse> { this.body = JSON.stringify(transactionRequest); this.headers = new HttpHeaders().set('Content-Type', 'application/json'); this.headers.append('Accept', 'application/json'); this.options = new RequestOptions({headers: this.headers}); return this.http.post<TransactionResponse>(this.baseUrl + '/transactions/' + transNumber + '/new', this.body, this

Embed json in ng-packagr

柔情痞子 提交于 2021-02-08 15:10:26
问题 In an angular cli project, I managed to embed json like this add to typings.d.ts declare module "*.json" { const value: any; export default value; } import .json import * as data from '../assets/data.json'; But if I want to compile this into an Angular 5 module with ng-packagr, I get the following error: Error at .../.ng_pkg_build/my-module/ts/src/app/my-module.module. ts:28:33: Cannot find module '../assets/data.json'. Did anyone encountered this issue and knows how to solve it? 回答1: Ng

I cannot use jsPDF with Angular 10

你离开我真会死。 提交于 2021-02-08 15:06:29
问题 I was trying to print my page using jspdf library. I've tried so many solutions to get it done following examples on here and almost every Google suggestion links but I still couldn't fix it. Here is what I've tried so far: import * as jsPDF from 'jspdf'; ..... openPDF(): void { const DATA = this.couponPage.nativeElement; const doc = new jsPDF('p', 'pt', 'a4'); doc.fromHTML(DATA.innerHTML, 15, 15); doc.output('dataurlnewwindow'); } Trying to import jsPDF like the above creates the following

I cannot use jsPDF with Angular 10

我的未来我决定 提交于 2021-02-08 15:05:40
问题 I was trying to print my page using jspdf library. I've tried so many solutions to get it done following examples on here and almost every Google suggestion links but I still couldn't fix it. Here is what I've tried so far: import * as jsPDF from 'jspdf'; ..... openPDF(): void { const DATA = this.couponPage.nativeElement; const doc = new jsPDF('p', 'pt', 'a4'); doc.fromHTML(DATA.innerHTML, 15, 15); doc.output('dataurlnewwindow'); } Trying to import jsPDF like the above creates the following

ng test fails in angular universal Error “Incomplete: No specs found, , randomized with seed 48751”

故事扮演 提交于 2021-02-08 15:00:36
问题 convert angular 7 project into angular universal while running "ng test" command giving error as " Incomplete: No specs found, , randomized with seed 48751 ". Tried different ways mention over stackoverflow but nothing work for me. ERROR in ./src/polyfills.ts Module build failed (from ./node_modules/@ngtools/webpack/src/index.js): Error: ../src/polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. at

ng test fails in angular universal Error “Incomplete: No specs found, , randomized with seed 48751”

谁说我不能喝 提交于 2021-02-08 15:00:25
问题 convert angular 7 project into angular universal while running "ng test" command giving error as " Incomplete: No specs found, , randomized with seed 48751 ". Tried different ways mention over stackoverflow but nothing work for me. ERROR in ./src/polyfills.ts Module build failed (from ./node_modules/@ngtools/webpack/src/index.js): Error: ../src/polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. at

Authorization header is not encrypted over HTTPS

谁说胖子不能爱 提交于 2021-02-08 14:11:09
问题 I am currently consuming a REST API which uses HTTP Basic Authentication. Based on the below picture, isn't the Authorization header supposed to be encrypted once I am using an Angular app over an HTTPS connection? 回答1: With HTTPS, the HTTP requests/responses are sent over an SSL/TLS connection. It ensures that the entire message (including the headers) is encrypted when it is sent over the wire . If anyone intercepts the message, they won't be able to read the actual content. However, the

Authorization header is not encrypted over HTTPS

余生颓废 提交于 2021-02-08 14:08:28
问题 I am currently consuming a REST API which uses HTTP Basic Authentication. Based on the below picture, isn't the Authorization header supposed to be encrypted once I am using an Angular app over an HTTPS connection? 回答1: With HTTPS, the HTTP requests/responses are sent over an SSL/TLS connection. It ensures that the entire message (including the headers) is encrypted when it is sent over the wire . If anyone intercepts the message, they won't be able to read the actual content. However, the

TS2416: Property 'canActivate' in type 'MyGuard' is not assignable to the same property in base type 'CanActivate'

橙三吉。 提交于 2021-02-08 13:57:58
问题 I have written an angular 4.3.0 typescript library. While building my library I saw below error in *.d.ts file. ERROR in [at-loader] ..\myLibrary\lib-commonjs\my-guard.service.d.ts:13:5 TS2416: Property 'canActivate' in type 'MyGuard' is not assignable to the same property in base type 'CanActivate'. Type '(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) => boolean | Promise | Observ...' is not assignable to type '(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) =>

ContentChildren with multiple content types

人走茶凉 提交于 2021-02-08 13:30:09
问题 Hello I am currently building a table that will allow multiple column types in it. I want to be able to use this like: <my-table [rows]="rows"> <text-column [someParameters]="here" header="text"></text-column> <icon-column [someParameters]="here" header="icon"></icon-column> </my-table> text-column and icon-column are separate directives. I currently have an abstract class called column and lets say the text-column and the icon-column may look something like: export abstract class Column {