Professional Documents
Culture Documents
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent{
title = "CodeSandbox";
num:number=40;
myfunc():void{
alert(this.num)
}
}
app.component.html content
<button (click)="myfunc()">String</button>
app.component.css
No content
Q Take your name as input from user in a text box. And show it on
alert box on the click of a button.
Answer:
app.component.ts file content
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
showText(title:string) {
if(title!=="")
{
alert(title);
}
else
{
alert("Fill the name first!!!");
}
}
}
app.component.html content
app.component.css content
Empty file
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
showText(n:number) {
if(n=='')
{
alert("Enter a valid number")
}
else
{
alert(n/2);
}
}
}
app.component.css file
div {
text-align: center;
}
app.component.html
Q Take a number as input in the code. Check whether the number is an armstrong
number or not. On the click of a button it should generate alert that “The number is
an armstrong number” or “The number is not an armstrong number”.
Q Create your one page CV on angular.