angular7

How to generate a PDF using Angular 7?

大城市里の小女人 提交于 2019-11-30 04:08:35
问题 I have to generate a PDF report from data entered by a user, which would be saved in an object. So far, I have come across stuff which generates an HTML page and then takes a screenshot and converts it into PDF. I am looking to generate a PDF directly from data stored in the object. Any ideas? 回答1: It is a common requirement, but you haven't provided much detail on specific requirements of your PDFs. You can look at: https://www.npmjs.com/package/angular-pdf-generator or https://parall.ax

Angular 7 app getting CORS error from angular client

橙三吉。 提交于 2019-11-30 03:25:25
问题 I have developed an angular 7 app with express backend. Express running on localhost:3000 and angular client is running on localhost:4200. In the server.js I have (not the entire code) const app = express(); // Enable CORS app.use(cors()); // Get our API routes const api = require('./api'); // Set our api routes app.use('/api', api); app.use(express.static(__dirname + '/dist/sfdc-event')); In the api.js file, I have router.get(‘/oauth2/login’) which redirects to https://example.com which

Improving production build time for Angular 7 application

折月煮酒 提交于 2019-11-29 17:54:28
问题 My application takes a very long time to build for production using ng build --prod Sometimes it even fails with FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory Is there something I can do to reduce the build time? 回答1: There are some things that can be done to reduce the build time. Increase the memory limit of the build process The build command is executed by node where a single process has a maximum memory limit of 1.76 GB on 64bit

How to set value to form control in Reactive Forms in Angular

坚强是说给别人听的谎言 提交于 2019-11-29 17:35:07
问题 Hi Everyone I'm new to angular. Actually, I'm trying to subscribe data from a service and that data, I'm passing to form control of mine from (example, it's like an edit form). import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormArray, FormControl } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; import { QuestionService } from '../shared/question.service'; @Component({ selector: 'app-update-que', templateUrl: '.

How to retrieve the value from LocalStorage

限于喜欢 提交于 2019-11-29 15:32:48
I'm trying to test out html5 localStorage feature. For some reason, whenever I try to retrieve a value from storage after refreshing the page, i dont get any value. Values are getting stored locally on my click functionality. But when i refresh the page, it doesnt show the values. src/app.component.ts File >import { Component } from '@angular/core'; >export class MyItems { >value: string; >constructor(value:string){ >this.value = value; > } >} >@Component({ >selector: 'my-app', >templateUrl: './app.component.html', >styleUrls: [ './app.component.css' ] >}) >export class AppComponent { >title =

angular 6 or 7: How to import RequestOptions and ResponseContentType in '@angular/common/http'

荒凉一梦 提交于 2019-11-29 14:39:54
问题 I have migrated angular 4 code to angular 6 and I want to know how to import below code in angular 6 or 7? import { RequestOptions, ResponseContentType } from '@angular/common/http'; 回答1: Pass this way ... import { HttpClient, HttpHeaders } from '@angular/common/http'; let headers = new HttpHeaders({ 'Content-Type': 'application/json' }); let options = { headers: headers } this.http.post(URL, param, options) .subscribe(data => { console.log(data); }); // For pass blob in API return this.http

cannot find name 'require' in angular 7(typescript 3.1.3)

十年热恋 提交于 2019-11-29 06:02:10
My question is why this error shown? ERROR in src/app/p2p/p2p.component.ts(14,16): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try npm i @types/node . I have install @types/node in app/tsconfig.app.json have add "types": [ "node" ], "typeRoots": [ "../node_modules/@types" ] but there is error cannot find 'require' The problem also remained after adding it to my tsconfig.json, but additionaly adding the following line to tsconfig.app.json resolved it for me: { "compilerOptions": { "types": ["node"] } So be sure to add this into both files .

How to retrieve the value from LocalStorage

筅森魡賤 提交于 2019-11-28 10:10:51
问题 I'm trying to test out html5 localStorage feature. For some reason, whenever I try to retrieve a value from storage after refreshing the page, i dont get any value. Values are getting stored locally on my click functionality. But when i refresh the page, it doesnt show the values. src/app.component.ts File >import { Component } from '@angular/core'; >export class MyItems { >value: string; >constructor(value:string){ >this.value = value; > } >} >@Component({ >selector: 'my-app', >templateUrl:

How to zoom charts in chart.js using angular 7

心已入冬 提交于 2019-11-28 09:55:15
问题 I have a line-chart and I want to zoom it but unable to do it. Here is my code let ctx = document.getElementById('myChart') let chart = new Chart(ctx, { type: 'line', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ label: '# of Votes', data: [7, 10, 3, 5, 2, 3], fill: true, backgroundColor: 'orange', borderColor: 'green', pointBorderColor: 'red', pointBackgroundColor: 'red' }] }, options: { plugins: { pan: { enabled: true, mode: 'x', onPan: function () {

Schematic input does not validate against the Schema: {“name”:“testng7”} on Angular 7

≡放荡痞女 提交于 2019-11-28 03:19:11
问题 I updated the Angular CLI to the latest @angular/cli@7.0.2 on a Mac OS. When issuing the command ng new testng7 , I get this error: Schematic input does not validate against the Schema: {"name":"testng7"} Errors: Data path "" should have required property 'version'. And nothing is created. Any clues how to fix? 回答1: This error is possible of avoiding naming standards Project name can not have underscore '_' . It can have dashes '-' , small and capital letters and digits . Valid Project Names