Angular 2 Building Blocks Hands-On Solutions
1. My Activity Tracker in Angular
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
//Define your variables done,todos,newToDo,newToDoObj,error
//Define your constructor here with todos as [] ,newToDo as '' and error as false
//Define your addMore function here
//Define your clearAll function here
public done: boolean;
public todos: any;
public newToDo: string;
public newToDoObj: any;
public error: boolean;
//public TODOS : Array;
constructor(){
this.todos = [];
this.newToDo = '';
this.error = false;
}
addMore(){
this.todos.push({done: true, item: this.newToDo});
}
clearAll(){
this.todos = [];
}
}
2. My First App With Angular
Create an Angular Application: -
app.component.ts:-
import { Component } from '@angular/core';
@Component({
// Add your code here for both selector and template
selector: 'app-root',
template:'<h1>My first angular app </h1>'
})
export class AppComponent {}
3. Interpolation in Angular:-
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `<h1>{{message}}</h1>`
})
export class AppComponent {
message = 'hey there';
}
4. Property Binding
app.component.html
<!--use your message property here using property binding-->
<span [innerHTML]="message">hey there</span>
5. Event Binding
app.component.html
Enter Your Name:
<input #userName type="text" value=''>
<button #btn (click)=welcomeMe(userName.value)> Welcome Me </button>
<br>
<h2> Message from Event Binding</h2>
<h3 id="output">
<!--add your welcome message with name like `Welcome <name>`-->
Welcome {{ name }}
</h3>
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html' //// refer app.component.html for property binding
})
export class AppComponent {
//Define your name and show variables here
//Define your welcomeMe(username) method here
name: string;
welcomeMe(name : string){
this.name = name;
}
}
6. Two Way Data Binding:-
app.component.html
Enter Your Name:
<input id="firstName" type="text" [(ngModel)]="name.first">
<input id="lastName" type="text" [(ngModel)]="name.last">
<br>
<h2>Message from Two way Binding</h2>
<h3 id="output">
<!--add welcome message here with first and last values of name-->
Welcome {{name.first}} {{name.last}}
</h3>
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
//Define your name object with first and last properties
name = {
first: "John",
last: "Smith"
};
}
Thank you for this, this is of great help, could you also please upload the handson code for "Directives in Angular" which is part of the same course?. That is the only handson seems to be missing here
ReplyDeleteDid u got directives code???
DeleteDid u got directives answer
DeleteNo
DeleteHi buddy thanks for this great help only I need is Directives in Angular 2 if u have please do let me know
DeleteWe Need Directives Answer
Deleteplease share directive code
DeleteI need help in directives in angular
Deletehttps://nitintyagi045.blogspot.com/2022/06/component-from-angularcore-component.html
DeleteSee answers for using directives handson at -
ReplyDeletehttps://embed.plnkr.co/or14Wh/
This is not working,thereis no display button
DeleteIt Passed,Thanks
Deleteit is showing test case failed
DeleteThis is not working. Only 2 test cases passed
DeleteIt Passed,Thanks
Deletehi there is no submit butten in the code
DeleteHi I'm always getting npm error in event binding . please help me .
ReplyDeletePlease share using directives answer
ReplyDeleteHii please help me in angular directive handson
ReplyDeletePlease provide directives angular2 hands on fresco play
ReplyDeleteEverything is perfect first of all thank you for guiding us. but here Directives handson is missing.
ReplyDeleteanyone please share answers for directives
ReplyDeletePlease anyone provide Angular2 -Newsapplication hands-on solution
ReplyDeletenews application solution?
Deleteyes please share me this its very argent
DeletePlease upload angular2 mini project course id-64449.
ReplyDeleteAnyone having angular 2 news application and Typescript hands on solutions pls share
ReplyDeletePlease share hands on of directives
ReplyDeletePlease provide angular 2 news application.
ReplyDeletepost angular 9 frescoplay
ReplyDeletePlease help us with directive answer
ReplyDeleteno need just copy and paste
DeleteHi.. please provide answer for "using directives ”” hands on
ReplyDeletei want web user interface design techniques hands on solution
ReplyDeleteweb ui design techniques hands on solution
ReplyDeleteBro pls upload using directives handson
ReplyDeletekindly upload directive handson solution
ReplyDeleteUpload using directive hands-on
ReplyDeletebro please upload using directives
ReplyDeletePlease provide answer for using directives also
ReplyDeleteShare angular2 using directives hand on
ReplyDeleteDirective Hands-on
ReplyDeleteimport { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
})
export class AppComponent {
constructor(){
this.selectedDay=0
}
show:boolean;
message:string;
selectedDay:number
selectedValue:string
days=[
{ 'today':'Monday','msg':'Marvelous Mondays!'},
{ 'today':'Tuesday','msg':'Thrilling Tuesdays!'},
{ 'today':'Wednesday','msg':'Wonderful Wednesdays!'},
{ 'today':'Thursday','msg':'Trendy Thursdays!'},
{ 'today':'Friday','msg':'Fantastic Fridays!'},
{ 'today':'Saturday','msg':'Super Saturdays!'},
{ 'today':'Sunday','msg':'Sunny Sundays!'}
]
//Define your variables show,message,selectedDay,selectedValue,days
//Define your constructor here with selectedDay as 0
}
Hi team,can you please share hands on for angular springboot stack(64904)
ReplyDeleteAny one who is looking for Directives handson solution please refer https://nitintyagi045.blogspot.com/2022/06/component-from-angularcore-component.html
ReplyDeleteAnyone having angular 2 news application and Typescript hands on solutions pls share
ReplyDeleteAnyone having angular 2 news application and Typescript hands on solutions pls share
ReplyDelete