if you want to generate a pdf file from datatable / Array or content in HTML Div : run this : 2. import : 3. create the datatable or the content to print in html div: 4. Create a button to generate PDF and put the as click action “generatePdf(contentToConvert)” 5. Finaly past this function […]
Catégorie: Angular
TypeScript – Variable : what is the difference between (var, let, const ) ?
TypeScript follows the same rules as JavaScript for variable declarations. Variables can be declared using: var let const The let declarations follow the same syntax as var declarations. but you have to know that, variables declared with let have a block-scope. Block-scope means that the scope of let variables is limited to their containing block, […]
Angular Date Pipe Formats
In HTML : and you can replace the fullDate with any format you like :
Solution for : Angular 2+ : If ngModel is used within a form tag, either the name attribute must be set or the form”
Angular 2+ Error !!! “If ngModel is used within a form tag, either the name attribute must be set or the form” Solution : If ngForm is used, all the input fields which have [(ngModel)]=”” must have an attribute name with a value.
Angular 10: what’s new ?
The new version of Angular, Angular v10 is officially available since June 25, 2020. With this new update of the framework, the Angular team continues to improve the framework and offers updates to the ecosystem, but also a review of various points that I present to you in this article. Since the release of Angular […]
The lifecycle of an Angular component
When developing an Angular application, it is important to understand how components work, including their lifecycle. This lifecycle is managed by Angular, so it’s Angular that will create the component, render it and finally destroy it when necessary. ngOnChanges: it is called when an input is defined or modified from the outside. The status of […]
How can I use an ng-if condition to look for a specific character ?
How can I use an ng-if condition to look for a specific character ? Solution : ES2015 have String#includes method that checks whether a string contains another. This can be used if the target environment supports it. The method returns true if the needle is found in haystack else returns false. Here, string/char is the […]
Angular – NgRx : Introduction !!
Les fondamentaux de NgRx, avec des exemples de code Quand j’ai commencé à travailler avec NgRx, j’ai été confronté à une courbe d’apprentissage abrupte. Il a fallu pas mal de lecture et de recherche pour comprendre les éléments de base de NgRx. L’objectif premier de cet article est de transmettre les connaissances que j’ai acquises […]
How to integrate Angular 8 with Camunda BPM ? (SOLVED – Git Repo)
To integrate Camunda with Angular Single Page (Version 6 / 8 / 9)Try this Git repository : Camunda + Angular https://github.com/marwenmselmi/camunda-angular-6-8-9
How to check if value exists in enum in TypeScript
Solution : If you get an error for: Property ‘values’ does not exist on type ‘ObjectConstructor’, then you are not targeting ES2017. You can either use this tsconfig.json config: Or you can just do an any cast:
Solution for : An unhandled exception occurred: Job name “..getProjectMetadata” does not exist
Problem : When I start to run my Application, I get this error: I have these versions: Angular CLI: 8.3.19, Node: 12.14.0. Any Idea what causes this problem ? Solution It is a problem with @angular-devkit/build-angular. Try updating it by running : 2. Or downgrading it by specifying a previous version, such as
What is impure pipe in Angular ?
I am unable to understand impure pipes, some what better with pure pipes. Please explain with a simple and basic example ? Anser : A pure pipe is only called when Angular detects a change in the value or the parameters passed to a pipe. An impure pipe is called for every change detection cycle no matter […]
Solution for : Access to XMLHttpRequest from origin has been blocked by CORS policy
If you have this Error , when you are trying to consume an API using Angular and Spring The solution is : Jusd add the annotation @crossorigin in your RestController to allow your frontend consuming the API Read also : Solution for : net::ERR_CONNECTION_REFUSED in Angular
Solution for : net::ERR_CONNECTION_REFUSED in Angular
net::ERR_CONNECTION_REFUSED : I’d like to access an API server, but the server hasn’t started. Then I got the error : Could I handle this according to the status of the response ? Solution 1 : Solution 2 : If you are using spring for the backend , just add the annotation @crossorigin in your rest controller to […]
ANGULAR 9 : NOUVELLE VERSION ET AMÉLIORATIONS DU FRAMEWORK
Google est vraiment en train de se rattraper et a réussi à stabiliser le framework Angular (On se souvient de la catastrophe entre Angular 1 et Angular 2). Une chose est quasiment sûre, c’est qu’avec une nouvelle version tous les 6 mois, Google annonce clairement son intention de faire d’Angular un framework stable et mature. […]
Solution for : Angular 2+ how to set min or max date in input type date
Angular how to set min or max date in input type date ? How to set date input field’s max date to today ? Solution : You have to add this your TS file : Then in your template you add : Source

TypeScript : how to sleep a thread ?
If we need to sleep e thread, we can implements a delay method that returns a Promise object (which represents the eventual completion, or failure, of an asynchronous operation, and its resulting value) and through the setTimeout method (that sets a timer which executes a function or specified piece of code once after the timer expires) resolve […]

Angular : HTML to PDF with htm2canvas and jsPDF
Angular HTML to PDF htm2canvas jsPDF : Sometimes we need to export our HTML page into a PDF file. So how can we do this? There are two helpful tools that we can use to do this. The first is jsPDF that help us to produce a PDF file from an HTML content. The following is the […]

Asp Net Core 2 – Angular: download file from Controller
If we have an Angular client app that needs to download a file (for example a PDF file) from an Asp Net Core 2 api Controller , we can follow what is described in this post. The first implementation is on the server side (an Asp Net Core 2 Controller). So, for example into our controller UserController, […]

Type Script : sum of object properties within an array
If we need to sum a simple array, we can use the reduce method, that executes a reducer function (that you provide) on each member of the array resulting in a single output value. For example: But if we have an objects array like the following: We need to use the map method (that creates a new array […]