What is observable, observer and subscribe in angular?

Here is a simple visual to see the difference: As seen above … an Observable is a stream of events or data. They are often returned from Angular methods, such as the http.get and the myinputBox.valueChanges. Subscribing “kicks off” the observable stream. Without a subscribe (or an async pipe) the stream won’t start emitting values. … Read more

Angular 6 library shared stylesheets

For global styles, I’ve answered it in this question. Update For ng-packgr versions 9.x and above Copying assest to output folder is now directly supported as explained in this page { “$schema”: “./node_modules/ng-packagr/package.schema.json”, “name”: “@my/library”, “version”: “1.0.0”, “ngPackage”: { “assets”: [ “CHANGELOG.md”, “./styles/**/*.theme.scss” ], “lib”: { … } } } So in your project you … Read more

Convert HTML to PDF in Angular 6 [closed]

Best possible solution I could come up with till now. You would have to install the below packages from npm html2canvas jspdf import * as jsPDF from ‘jspdf’; import html2canvas from ‘html2canvas’; htmltoPDF() { // parentdiv is the html element which has to be converted to PDF html2canvas(document.querySelector(“#parentdiv”)).then(canvas => { var pdf = new jsPDF(‘p’, … Read more

Angular6 What’s browserTarget

browserTarget is a setting that maps a configuration to a build target e.g. build, serve, test, lint. It’s kind of a funny name. To be honest I don’t know why it’s called browserTarget instead of just target. Further reading here at the angular.io docs.

Angular 6, should I put secret environment variables in environment.ts file?

TL; DR You should not treat environment.ts as something similar to process.env. The name is similar but the behaviour is absolutely not. All the settings from environment.ts will directly go to your code. That’s why it is not secure to put secrets to environments.ts in any way. The browser alternatives to environment variables (process.env) are … Read more

What is the proper way to use a dependent npm package in angular 6 library project?

It looks like adding the package name to a “whitelistedNonPeerDependencies” collection in the ng-package.json file will resolve this build issue. I’m still not sure what the best practice is here though. Should we create angular libraries that have dependancies on other npm packages or is it best to only have peerDependancies? ng-package.json file: { “$schema”: … Read more

tech