How to check string equality in Typescript ? If you need to check the equality of two string in Typescript the best way will be using the === operator . If you need to check if two string are twins or no read this post !!
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
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 […]
If we need to clone an object we can use the Object.assign method. We can use this method to copy the values of all enumerable own properties from one or more source objects to a target object. It will return the target object.
If we have an array (even not ordered) and we want to remove duplicated values, we can use the filter method:
The map() method is helpful to creates a new array with the results of calling a provided function on every element in the calling array. Suppose that we have two classes: And we have an Angular service called ‘myService‘ that through a .getObjects() method returns the following data: If we need to fill a DestinationType array […]
Disable Input fields in reactive form from type Script If you want to disable some input of your formBuilder from the TS File , you can use this code : Or
if you need to get the difference between two dates in days. you can use this function : if you are using the date as a String you can have this error getTime() is not a function ! so if you have this error try this solution
Problem How to have a default option using angular 2 ou plus ? Solution if you have a select and you want to set a default value using angular , Add a binding to the selected property, like this : Read also : How to click on html button from the type script file in […]
Problem if i have this code : How can I select the default value from typescript for example 45 ? Solution You can do this :
How to click on html button from the type script file in Angular 2 ? Some time we need to click into a button from the ts File to run one action, to do this you can try this solution (even if it is a hidden button) : Solution : On ts File use the […]
Angular get current year – typescript get current year : In you are using Angular and you need to get current year Try this code :