What is Angular Material? Angular Material is a UI/UX library for Angular developers. Just like Bootstrap, Angular Material provides a bunch of in-build components like Bootstrap includes a bunch of classes. Implementation of Angular Material is way more different than Bootstrap. We will see about that later in this article.
Why Should You Use Angular Material? If you are using Angular for application development, Angular Material is one of the best and easiest ways of creating a decent and attractive UI.
[Read More]
JavaScript, Display Date Only
How to display only Date From JavaScript Date Time?
The Logic: JavaScript date object has methods to extract the date, month, and year. We’ll utilize it to build the date from the DateTime.
function getDate(dateTime){return `${dateTime.getDate()}-${dateTime.getMonth() + 1}-${dateTime.getFullYear()}`}console.log('Date is ', getDate(new Date()));// "Date is ", "25-11-2020"getMonth method returns the month index from 0 to 11 from January to December respectively. That’s why it’s been incremented by 1 for display.
[Read More]
Python : SyntaxError: Missing parentheses in call to print
SyntaxError: Missing parentheses in call to ‘print’.
It’s been a while since I did some Python code. I updated to Python 3.8 from Python 2.7. While trying to run a program written in Python2.7 under Python3.8 I’m getting the above error.
Python 3.8.0>>> print "Hello World"File "<stdin>", line 1print "Hello World"^SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Hello World")print statement has been replaced by print() function.
[Read More]
JavaScript, Split Number To Digits
How to split a number to Digits using JavaScript?
The Logic: Convert the number to string, split it into a string array and convert each string to number
function splitNumber(num){
return String(num).split('').map(item => Number(item))
}
console.log('Number array is ', splitNumber(123));
// "Number array is ", [1, 2, 3]
Python, Capitalize First Letter Of All Sentences
How to capitalize the first letter of all the sentences or how to capitalize the first letter in a paragraph using Python.
Let’s take some sample text.
sample_text = "lorem ipsum dolor sit amet, consectetur adipiscing elit. aliquam ornare volutpat magna ut euismod. vivamus vitae placerat erat. nulla facilisi. praesent ante mi, sodales sagittis condimentum vel, elementum nec augue."The logic: We split the paragraph based on . (dot) to get a sentence list.
[Read More]
Python, Capitalize First Letter In A Sentence
How to capitalize first letter of first word in a sentence using Python?
Method 1: Using Upper The logic is simple. Take the first letter of the sentence, make it upper and join it to the rest of the sentence.
Python 3.8.0>>> str = "it's hello word way to go">>> "".join([str[0].upper(),str[1:]])"It's hello word way to go"Method 2: Using Capitalize Python has a built in method which can be used to capitalize the first letter of the sentence.
[Read More]
How to Improve Programming Skills in Python
If you have worked in the programming field, or even considered going into programming, you are probably familiar with the famous words of Apple founder Steve Jobs:
“Everyone in this country should learn to program a computer, because it teaches you to think.”
Python is one of the most popular programming languages and can teach us a lot about critical thinking. But if you are in programming, you also know that there are important reasons to keep your programming skills up to date, especially with Python.
[Read More]
Python, Check String Contains Another String
How to check if a string contains another string using Python.
Method 1: Using find find method returns the index of the substring in a string.
>>> "welcome to my world".find("my")11Using find you can check if a string contains another string or substring.
One gotcha with using the find method is it doesn’t know whether to look for the whole word or partial. For example,
>>> "there is a goal post".
[Read More]
How To Add Custom Validation To Angular Reactive Form
In this tutorial, you’ll learn how to add custom validation to Angular Reactive Form. This is the fourth part of the Angular Material Reactive Form Tutorial Series. In the previous part, you learned how to validate the Angular Reactive form. So, let’s get started.
Source code from this tutorial is available on GitHub.
Getting Started Let’s get started by cloning the source from the third part of the tutorial series.
[Read More]
How to Validate Angular Material Radio Button In Reactive Form
In this tutorial, you’ll learn how to validate the Angular Material Radio button group in Reactive Forms. Let’s get started by installing Angular Material and setting up it in an Angular project.
Source code from this tutorial can be found on GitHub.
Once you have Angular Material all set up, let’s include the MatRadioModule in the app.module.ts file:
import { BrowserModule } from '@angular/platform-browser';import { NgModule } from '@angular/core';import { AppComponent } from '.
[Read More]