Posts

Angular: building basic calculator

Image
Introduction In this tutorial, we will walk through the steps to create a simple calculator application using Angular. This exercise is designed to help you practice your Angular skills and understand the basics of building a user interface and handling events. Prerequisites Before you begin, ensure you have the following: Basic understanding of Angular Angular CLI installed Node.js and npm installed Step 1: Setting Up the Project First, let's create a new Angular project. Open your terminal and run: ng new BasicCalculator  cd BasicCalculator  ng serve This will set up a new Angular project and start the development server. You can view the default application by navigating to http://localhost:4200 in your browser. Step 2: Designing the Calculator UI In app.component.html, design the UI of the calculator. Here's a simple structure to get you started: <div class="container"> <div class="calculator"> <div><input class=&

Beginner: Temperature Converter in C#

Image
Introduction In this tutorial, we will create a simple console application in C# that converts temperatures between Celsius, Fahrenheit, and Kelvin. This is a great project for beginners to practice basic programming concepts and console input/output operations. Code Implementation: ITemperatureConverter internal interface ITemperatureConverter { TemperatureUnit ReadConvertUnit(string baseUnit); bool IsInputValid(string baseValue, TemperatureUnit baseUnit, TemperatureUnit targetUnit); decimal Process(string baseUnitValue, TemperatureUnit baseUnitEnum, TemperatureUnit targetUnitEnum); } TemperatureDataService Read user input public TemperatureUnit ReadConvertUnit(string inputUnit) { if (!int.TryParse(inputUnit, out var unit)) { Console.WriteLine("Invalid temperature unit. Please enter convert unit: "); inputUnit = Console.ReadLine(); ReadConvertUnit(inputUnit);

Building an Angular App: To-Do list

Image
Introduction In this post, I'll share my experience building a small Angular application called "To-Do List". This is a practice project to delve deeper into Angular concepts. Application Overview Simple angular application Basic Angular concepts No API calls Pure front-end implementation Code Snippet app.component.html <div class="container-fluid"> <div class="container"> <div class="row align-items-center"> <div class="col-4"> <div class="card"> <div class="card-header"> <label for="exampleFormControlInput1" class="form-label">Add to-do</label> </div> <div class="card-body"> <h5 class="card-title">New Do It</h5> <input type="text" class="form-control" [(ngModel)]="toDoValue" i

Palindrome Checker

Image
C# Exercise: Palindrome Checker C# Exercise: Palindrome Checker Description Write a C# program that checks if a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, ignoring spaces, punctuation, and capitalization. For example, "radar" and "A man a plan a canal Panama" are palindromes. Program.cs Console.WriteLine("Enter a text to check if it is a palindrome"); var text = Console.ReadLine(); var check = new PalindromeChecker.Class.PalindromeChecker(); if (string.IsNullOrEmpty(text)) Console.WriteLine("Text value empty"); if (check.IsPalindrome(text)) Console.WriteLine($"'{text}' is a palindrome"); else Console.Writ
Image
C# Exercise: Fibonacci Sequence C# Exercise: Fibonacci Sequence Description Write a C# program to generate the Fibonacci sequence up to a specified number of terms. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. For example, the first few numbers in the Fibonacci sequence are 0, 1, 1, 2, 3, 5, 8, 13, 21, ... Your program should prompt the user to enter the number of terms they want in the Fibonacci sequence and then output the sequence up to that number of terms. Exercise Console.WriteLine("Enter the number of terms for the Fibonacci sequence:"); var numTerms = Convert.ToInt32(Console.ReadLine()); var iteration = 0; var firtNumber = 0; var secondNumber = 1; var nextNumber = 0;

Angular : Setup

Image
Download Node.js Download Node.js NVM (Node Version Manager) Download and install NVM: GitHub - coreybutler/nvm-windows Command: Install a version of Node: nvm install 14.15.1 Use a version installed: nvm use 14.15.1 List all installed Node versions: nvm list Install Angular CLI npm -g @angular/cli Create Project Create a new Angular project: ng new [AppName] Or with a specified prefix: ng new [AppName] --prefix [PrefixName] All generated components will have the prefix in the selector o

Angular : introduction

Features of Angular Two-Way Data Binding Data binding is automatic and fast. Changes made in the View are automatically updated in the component class and vice versa. Powerful Routing Support The Angular Powerful routing engine loads the page asynchronously on the same page, enabling us to create Single Page Applications. Expressive HTML Angular enables us to use programming constructs like if conditions, for loops, etc., to render and control HTML pages. Modular by Design Angular follows the modular design. You can create Angular modules to better organize and manage our codebase. Built-in Back End Support Angular has built-in support to communicate with the back-end servers and execute any business logic or retrieve data

Angular: Architecture overview and concepts

The first big change in Angular over AngularJs is Components. Components replace the Controllers of AngularJs. But that is where the similarity ends. Angular Components do not look like Controllers. The Components are actually similar to the directives of AngularJs. Angular Architecture The architecture of an Angular Application is based on the idea of Components. An Angular application starts with a Top-level component called Root Component. We then add child components forming a tree of loosely coupled components. Angular Modules The Angular provides a nice way to organize Components, Services, Directives by using the concept called Angular Modules. Special directives are used to create the Modules. The Angular Module is also called ngModule. Use Angular Module (or ngModule) to organize all the Angular code within a bigger Angular Application. The Application is made up of several Angular Modules acting toge

Angular: Creating new project

Image
What is Angular CLI The Angular CLI helps us to quickly create an Angular application with all the configuration files and packages in one single command. It also helps us to add features (components, directives, services, etc) to existing Angular applications. The Angular CLI creates the Angular Application and uses: Typescript, Webpack ( for Module bundling), Karma ( for unit testing), Protractor ( for an end-to-end testing). How to Create a new Angular project Before starting with Angular, you need to set up your developer environment and install the required tools. Before going further install the following: Visual Studio Code (or any other editor of your choice) NPM Package Manager Installing Angular CLI The first step is to install the Angular CLI. We use the npm install command. npm install -g @angular/cli@latest The above command installs the latest version

Angular: Bootstrapping in angular

Image
What is Bootstrapping? Bootstrapping is a technique of initializing or loading our Angular application. Let’s walk through the code created in "Create your First new Angular project" and see what happens at each stage and how our AppComponent gets loaded and displays “app works!”. Angular takes the following steps to load our first view: Index.html loads: The initial HTML file is loaded into the browser. Angular, Third-party libraries & Application loads: Angular framework and any third-party libraries are loaded. Main.ts - the application entry point: The main.ts file is executed, which bootstraps the Angular application. Root Module: The root module ( AppModule ) is loaded. This module organizes the application code and defines the components, services, and other features used in the application. Root Component: The root component ( AppComponent ) is loaded. This component serves as the starting point of the application and is defin