angular

how to get array of object instead of object in angular?

倾然丶 夕夏残阳落幕 提交于 2021-02-08 16:54:40
问题 can you please tell me how to get array of objects instead of object in angular 2.I am hitting a service and getting a object as a response . getUsers(): Observable<HttpResponse<UserModel>> { return this.http.get<HttpResponse<UserModel>>(this.configUrl).pipe( catchError(this.handleError) ); } getting response this { "page": 1, "per_page": 3, "total": 12, "total_pages": 4, "data": [ { "id": 1, "first_name": "George", "last_name": "Bluth", "avatar": "https://s3.amazonaws.com/uifaces/faces

Angular HttpClient authorization header created but disappearing

不问归期 提交于 2021-02-08 15:36:13
问题 Problem I am trying to send Request Headers, specifically, an authorization header. The authorization Header should look something like this: Authorization: Basic NTY2MTI0Og== In a list of headers. Where Basic indicates that it is encoded with base64. I'm positive it does get added to the get request made in Angular: Request in Angular. Although I'm not sure what op is. (btw, I'm not yet allowed to embed the image) This is what it should look like: From the standard Datasnap Delphi project

Angular 4: Web API call mapping not working. ProgressEvent returned with error

这一生的挚爱 提交于 2021-02-08 15:33:46
问题 I am trying to call a web api end point using code like this. verifyUserLogin(userName: string, password: string): Observable<UserSession> { let observable = this._http.get(this.baseUrl + "?userName=" + encodeURIComponent(userName) + "&password=" + encodeURIComponent(password)); return observable .map(this.convertResponseToUserSession) .do(data => this.logData(data)) .catch(this.handleError); } The conversion function in the map call is as follows. private convertResponseToUserSession (res:

plain objects VS class instances for model objects

冷暖自知 提交于 2021-02-08 15:20:14
问题 What is the best practice for creating model objects in Angular / TypeScript: Should I use type annotation with object notation (objects are plain instances of Object )? E.g. let m: MyModel = { name: 'foo' } Should I use the new operator (objects are instances of the respective prototype)? Should these two approaches be mixed up and used situationally? (E.g plain objects, when receiving a response from the HttpClient , but new MyModel('foobar') for convenience to create instances by passing

async/await __generator is not defined

旧街凉风 提交于 2021-02-08 15:16:44
问题 I am trying to use async/await functions with angular2-webpack-starer and typescript (which now have support for this functions targeting es5), but I'm getting error: This is code inside component: // function inside component async checkSlug(slug: string) { // nothing here } I am using webpack2.2 and typescript 2.1.5. This is my tsconfig: { "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true,

Angular and datalist

本小妞迷上赌 提交于 2021-02-08 15:14:39
问题 I need some help understanding how to use the HTML datalist with Angular. I have an object here. I would like the dropdown to display the make and model of the cars. But when you select a car , the selectedCar variable should be the entire car object. But the input should still only show the make and model . cars = [{ make: 'Ford', model: 'GTX', color: 'green' }, { make: 'Ferarri', model: 'Enzo', color: 'red' }, { make: 'VW', model: 'Amarok', color: 'white' }] ... <input list="id-car" [

Angular and datalist

我的未来我决定 提交于 2021-02-08 15:13:53
问题 I need some help understanding how to use the HTML datalist with Angular. I have an object here. I would like the dropdown to display the make and model of the cars. But when you select a car , the selectedCar variable should be the entire car object. But the input should still only show the make and model . cars = [{ make: 'Ford', model: 'GTX', color: 'green' }, { make: 'Ferarri', model: 'Enzo', color: 'red' }, { make: 'VW', model: 'Amarok', color: 'white' }] ... <input list="id-car" [

fs.existsSync is not a function when used in electron

烈酒焚心 提交于 2021-02-08 15:12:46
问题 I am using Angular 10 , Electron 10.0 and electron-builder v22.8.0 . When starting my Electron app, I receive the following error in the console: fs.existsSync is not a function when used in electron getElectronPath @ ./node_modules/events/events.js:6 <anonymous> @ ./node_modules/events/events.js:17 ./node_modules/electron/index.js @ ./node_modules/events/events.js:19 __webpack_require__ @ ./webpack/bootstrap:79 ./src/app/projectview/new/new.component.ts @ ./src/app/projectview/new/new

fs.existsSync is not a function when used in electron

瘦欲@ 提交于 2021-02-08 15:11:18
问题 I am using Angular 10 , Electron 10.0 and electron-builder v22.8.0 . When starting my Electron app, I receive the following error in the console: fs.existsSync is not a function when used in electron getElectronPath @ ./node_modules/events/events.js:6 <anonymous> @ ./node_modules/events/events.js:17 ./node_modules/electron/index.js @ ./node_modules/events/events.js:19 __webpack_require__ @ ./webpack/bootstrap:79 ./src/app/projectview/new/new.component.ts @ ./src/app/projectview/new/new

Embed json in ng-packagr

此生再无相见时 提交于 2021-02-08 15:10:37
问题 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