Skip to main content

Featured Post

What is Salesforce ? Who is salesforce developer?

  1. Introduction to Salesforce Definition : Salesforce is the #1 Cloud-based CRM (Customer Relationship Management) platform that helps businesses manage relationships with customers, automate business processes, and analyze performance. Founded : 1999 by Marc Benioff. Type : SaaS (Software as a Service). Tagline : "No Software" – because everything runs on the cloud, without local installations. 2. Why Salesforce? Traditional CRMs were expensive and required servers, installations, and IT staff. Salesforce revolutionized CRM by moving everything to the cloud . Benefits: 🚀 Faster implementation ☁️ Cloud-based (accessible anywhere) 🔄 Customizable without coding (point-and-click tools) 🤝 Strong ecosystem & AppExchange (marketplace like Google Play for Salesforce apps) 🔐 Security & scalability 3. Salesforce Products & Cloud Offerings Salesforce is not just CRM; it has multiple clouds (modules) for different busine...

Angular Framework 17.0 Tutorials

Angular Framework Introduction

.......................................................................................................................................................................

 


before study this first you learn JS and Jquery:-

https://www.shivatutorials.com/search/label/JAVASCRIPT

https://www.shivatutorials.com/search/label/Jquery


It is a javascript framework which provides an MVC design pattern to develop dynamic web application using HTML and JavaScript Object.

MVC means Model, View, and Controller, it is used to distribute the project on different project layer.


Angular JS-Support JavaScript code  and Typescript code. structure to write Business Code.


The flow of MVC:-

MVC flow is the opposite of there name.


The First Controller module will be loaded then View will be loaded after that model object will be integrated.


                                              Controller

              View                                                         Model



Controller:-   It is used to provide routing and business code of an application using Javascript.

                        we will write JavaScript code to create a controller



View:-   HTML web page will work to implement View,it will provide a dynamic User interface to bind Html data to the model object.


Model:-  it contains data of the application and shows into view.


 Angular provides an angular plugin which contains angular libraries to use angular functionality.






 
Difference between Angular Js and Angular:-


Angular Js is the initial version of angular it is also called angular 1.0.

It uses Javascript to write code and it is fully dependent on HTML documents.

It provides MVC design patterns to develop dynamic applications but it is not compatible with mobile application development.


hence Angular Js 2.0,4.0,5.0,6.0,7.0 and 8.0 , 17 version has been released which uses TypeScript (Object-Oriented JavaScript ) to write code and it is completely depend on Module and Component-based architecture.

 
How to create App in Angular without state.

Step 1st:

ng new myangproject --no-standalone

Step2nd:-

Create Controller
 
ng g c addition

Step3rd:-

import FormsModule under app.module.ts file

update file after adding FormsModule

import { NgModule } from '@angular/core';
import { BrowserModule, provideClientHydration } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AdditionComponent } from './addition/addition.component';
import { FormsModule } from '@angular/forms';

@NgModule({
  declarations: [
    AppComponent,
    AdditionComponent
  ],
  imports: [
    FormsModule,
    BrowserModule,
    AppRoutingModule
  ],
  providers: [
    provideClientHydration()
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }



Step4th:

Create Addition form designing under angular component design file

<p>addition works!</p>
<input type="number"  [(ngModel)]="a" placeholder="Enter First Number"  />
<br/><br/>
<input type="number"  [(ngModel)]="b" placeholder="Enter Second Number"  />
<br/><br/>
<input type="button" value="Addition" (click)="add()" />
<br/>
{{c}}

Step5th:-

import { Component } from '@angular/core';

@Component({
  selector: 'app-addition',
  templateUrl: './addition.component.html',
  styleUrl: './addition.component.css'
})
export class AdditionComponent {
  a:number=12
  b:number=2
  c:number=0
  add():void {
    this.c = this.a+this.b;
   
  }
}


2) Create Another Example of Angular to implement Addition, Subtraction, Multiplication and Division
using four separate button.

Create Component and Add following code on Html file:

<p>addition works!</p>
<input type="number"  [(ngModel)]="a" placeholder="Enter First Number"  />
<br/><br/>
<input type="number"  [(ngModel)]="b" placeholder="Enter Second Number"  />
<br/><br/>
<input type="button" value="Addition" (click)="add($event)" />
<br/>
<input type="button" value="Substraction" (click)="add($event)" />
<br/>
<input type="button" value="Multiplication" (click)="add($event)" />
<br/>
<input type="button" value="Division" (click)="add($event)" />
{{c}}


Write following code under typescript file

import { Component } from '@angular/core';

@Component({
  selector: 'app-addition',
  templateUrl: './addition.component.html',
  styleUrl: './addition.component.css'
})
export class AdditionComponent {
  a:number=12
  b:number=2
  c:number=0
  param=null;
  add(event:any):void {
    this.param = event.target.value;
    if(this.param=="Addition")
    {
    this.c = this.a+this.b;
    }
    else if(this.param=="Substraction")
    {
      this.c = this.a-this.b;
    }
    else if(this.param=="Multiplication")
    {
      this.c = this.a*this.b;
    }
    else if(this.param=="Division")
    {
      this.c = this.a/this.b;
    }
    alert("hello"+this.a);
  }
}



3) How to bind data in dropdownlist

 Declare array in typescript file

courses = ['C', 'C++','DS', 'JAVA'];

Display data under html file

<select >
    <option *ngFor="let c of courses" [value]="c">{{c}}</option>
  </select>
  <br/>
  <select multiple>
    <option *ngFor="let c of courses" [value]="c">{{c}}</option>
  </select>

Create Angular Form using Radiobutton, Checkbox, Dropdownlist and Listbox:-

Code of Design File:-

<p>myform works!</p>
<hr/>
<select [(ngModel)]="course">
    <option value="">Select Course </option>
    <option *ngFor="let c of courses" [value]="c">{{c}}</option>
  </select>
   <br/><br/>
   <p>Select Course</p>
   <select [(ngModel)]="course1" multiple>
   
    <option *ngFor="let c of courses" [value]="c">{{c}}</option>
  </select>
   <br/><br/>
   <input type="radio" value="JAVA" name="basic" [(ngModel)]="advance"/>Java<br/>
   <input type="radio" value=".NET" name="basic" [(ngModel)]="advance"/>.NET <br/>
   <br/><br/>
   <input type="checkbox" value="C" name="basic1" [(ngModel)]="basic1"/>C <br/>
   <input type="checkbox" value="CPP" name="basic2" [(ngModel)]="basic2"/>CPP <br/>
   

    <input type="button" value="Submit" (click)="displayData()" />
  <br>
  {{result}}

Code of Javascript:-

import { Component } from '@angular/core';

@Component({
  selector: 'app-myform',
  templateUrl: './myform.component.html',
  styleUrl: './myform.component.css'
})
export class MyformComponent {
  courses = ['C', 'C++','DS', 'JAVA'];
  course='';
  course1='';
  result = '';
  basic1 = '';
  basic2 = '';
  advance='';
  displayData():void
  {
    var arr= this.course1;
    var data='';
    var s1='',s2='';
    for(var i=0;i<arr.length;i++)
    {
        data = data + arr[i] + " ";
    }
    if(this.basic1)
    {
       s1=" C ";
    }
    else
    {
      s1 = " ";
    }
    if(this.basic2)
    {
       s2 = " CPP ";
    }
    else{
      s2 = '';
    }
    this.result = "Selected Course is "+this.course + " Other courses "+data + " Basic Course is "+ (s1 + s2) + " Advance course is "+this.advance;
    // alert("Selected Course is "+this.course + " Other courses "+data);
  }
}


How to pass parameter to one component to another:-

1)  First create path 
2) create First Component:-

import { Router } from '@angular/router';

submitData3()
{
  var id = 10
  this.router.navigate(['/addition',id]);
}

Code of Design File

 <input type="button" value="Addition Component" (click)="submitData3()" />


3) Create Addition Component to get the data from Url:-

import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@Component({
  selector: 'app-addition',
  templateUrl: './addition.component.html',
  styleUrl: './addition.component.css'
})
export class AdditionComponent {
 
  data:number=0;
 
  constructor(private activatedRoute: ActivatedRoute) {}
  ngOnInit() {
    // Subscribe to the route parameter changes
    this.activatedRoute.params.subscribe(params => {
      // Retrieve the 'id' parameter from the route
      this.data = +params['id']; // Convert to a number if needed
    });
  }
 
}


write code on additioncomponent.html

{{data}}



Angular Form 17 Validation:-

First Install bootstrap 
npm install bootstrap@4.6.2

add configuration under angular.json

"styles": [
    "node_modules/bootstrap/dist/css/bootstrap.min.css",
    "src/styles.css"
],
"scripts": [
    "node_modules/jquery/dist/jquery.slim.min.js",
    "node_modules/popper.js/dist/umd/popper.min.js",
    "node_modules/bootstrap/dist/js/bootstrap.min.js"
]

 Import Module under app.modul.ts file:-

import { FormsModule,ReactiveFormsModule} from '@angular/forms';

imports: [
    FormsModule,
    ReactiveFormsModule,

  ]

Step3rd:-

Create Component

Write following code on .ts file

import { Component } from '@angular/core';
import {ReactiveFormsModule} from '@angular/forms';
import {FormGroup, FormControl, Validators } from '@angular/forms';
@Component({
  selector: 'app-formvaliation',
  templateUrl: './formvaliation.component.html',
  styleUrl: './formvaliation.component.css'
})
export class FormvaliationComponent {
  form = new FormGroup({
    name: new FormControl('', [Validators.required, Validators.minLength(3)]),
    email: new FormControl('', [Validators.required, Validators.email]),
    body: new FormControl('', Validators.required)
  });
  get f(){
    return this.form.controls;
  }
  submit(){
    console.log(this.form.value);
  }
}


write following code in .html file

<p>formvaliation works!</p>
<form [formGroup]="form" (ngSubmit)="submit()">
       
    <div class="form-group">
        <label for="name">Name</label>
        <input
            formControlName="name"
            id="name"
            type="text"
            class="form-control">
        <div *ngIf="f['name'].touched && f['name'].invalid" class="alert alert-danger">
            <div *ngIf="f['name'].errors && f['name'].errors['required']">Name is required.</div>
            <div *ngIf="f['name'].errors && f['name'].errors['minlength']">Name should be 3 character.</div>
        </div>
    </div>
     
    <div class="form-group">
        <label for="email">Email</label>
        <input
            formControlName="email"
            id="email"
            type="text"
            class="form-control">
        <div *ngIf="f['email'].touched && f['email'].invalid" class="alert alert-danger">
            <div *ngIf="f['email'].errors && f['email'].errors['required']">Email is required.</div>
            <div *ngIf="f['email'].errors && f['email'].errors['email']">Please, enter valid email address.</div>
        </div>
    </div>
     
    <div class="form-group">
        <label for="body">Body</label>
        <textarea
            type="text"
            formControlName="body"
            id="body"
            rows="5"
            cols="50"
            class="text-area"></textarea>

       
        <div *ngIf="f['body'].touched && f['body'].invalid" class="alert alert-danger">
            <div *ngIf="f['body'].errors && f['body'].errors['required']">Body is required.</div>
        </div>
    </div>
   
    <button class="btn btn-primary" [disabled]="form.invalid" type="submit">Submit</button>
</form>




Comments

Popular posts from this blog

Conditional Statement in Python

It is used to solve condition-based problems using if and else block-level statement. it provides a separate block for  if statement, else statement, and elif statement . elif statement is similar to elseif statement of C, C++ and Java languages. Type of Conditional Statement:- 1) Simple if:- We can write a single if statement also in python, it will execute when the condition is true. for example, One real-world problem is here?? we want to display the salary of employees when the salary will be above 10000 otherwise not displayed. Syntax:- if(condition):    statements The solution to the above problem sal = int(input("Enter salary")) if sal>10000:     print("Salary is "+str(sal)) Q)  WAP to increase the salary of employees from 500 if entered salary will be less than 10000 otherwise the same salaries will be displayed. Solution:- x = int(input("enter salary")) if x<10000:     x=x+500 print(x)   Q) WAP to display th...

DSA in C# | Data Structure and Algorithm using C#

  DSA in C# |  Data Structure and Algorithm using C#: Lecture 1: Introduction to Data Structures and Algorithms (1 Hour) 1.1 What are Data Structures? Data Structures are ways to store and organize data so it can be used efficiently. Think of data structures as containers that hold data in a specific format. Types of Data Structures: Primitive Data Structures : These are basic structures built into the language. Example: int , float , char , bool in C#. Example : csharp int age = 25;  // 'age' stores an integer value. bool isStudent = true;  // 'isStudent' stores a boolean value. Non-Primitive Data Structures : These are more complex and are built using primitive types. They are divided into: Linear : Arrays, Lists, Queues, Stacks (data is arranged in a sequence). Non-Linear : Trees, Graphs (data is connected in more complex ways). Example : // Array is a simple linear data structure int[] number...

Top 50 Most Asked MERN Stack Interview Questions and Answers for 2025

 Top 50 Most Asked MERN Stack Interview Questions and Answers for 2025 Now a days most of the IT Company asked NODE JS Question mostly in interview. I am creating this article to provide help to all MERN Stack developer , who is in doubt that which type of question can be asked in MERN Stack  then they can learn from this article. I am Shiva Gautam,  I have 15 Years of experience in Multiple IT Technology, I am Founder of Shiva Concept Solution Best Programming Institute with 100% Job placement guarantee. for more information visit  Shiva Concept Solution 1. What is the MERN Stack? Answer : MERN Stack is a full-stack JavaScript framework using MongoDB (database), Express.js (backend framework), React (frontend library), and Node.js (server runtime). It’s popular for building fast, scalable web apps with one language—JavaScript. 2. What is MongoDB, and why use it in MERN? Answer : MongoDB is a NoSQL database that stores data in flexible, JSON-like documents. It...