0% found this document useful (0 votes)
4 views2 pages

Demo Code Angular1

Uploaded by

rupams2024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Demo Code Angular1

Uploaded by

rupams2024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

app.component.

ts 27/03/2024
------------------
export class AppComponent {

city: string = "I am learning Angular";


path: string = "../assets/3.jpg";
cname: string = "special";
//d: string = new Date().toLocaleString();
d: string = new Date().toLocaleTimeString();

timeid = setInterval(() => {


this.d = new Date().toLocaleTimeString();
})
}
**********************************************
app.component.html 27/03/2024
-----------------
<h1>{{city}}</h1>
<!-- <div>
<img src="../assets/2.jpg" alt="no image">
</div>
<div>
<img src="{{path}}" alt="">
</div> -->
<h1 class="special special1">This is a heading</h1>
<h1 class={{cname}}>This is a heading</h1>
<h1>{{d}}</h1>
*************************************************
app.component.css 27/03/2024
------------------
.special {
border: 3px solid green;
}

.special1 {
background-color: blue;
color: white;
}
*************************************************
2-4-2024 app.component.html
================
Name: <input type="text">
<!--<button disabled="{{isdisabled}}">Submit</button>-->
<input type="text" [hidden]=ishidden /><!--Property binding-->
<!--<button [disabled]=isdisabled>Submit</button>--><!--Property binding-->
<img [src]=path alt="" /><!--Property binding-->
<button>Submit</button>

app.component.ts
=================
export class AppComponent {

//isdisabled: boolean = false;


ishidden: boolean = true;
path: string = "../assets/2.jpg";
}
4-4-2024 app.component.html
<h1 [class]="isactive?'active':'inactive'">This is heading.</h1>
<h1 [class]="{c1:true}">This is heading.</h1>
<h1 [class]="{c1:applyc1}">This is heading.</h1>
<h1 [class]="{c1:applyc1,active:isactive}">This is heading.</h1>
<h1 [class]="['c1','active']">This is heading.</h1>
<h1 [class.active]=isactive>This is heading.</h1>

app.component.ts
=================
export class AppComponent {

isactive: boolean = true;


applyc1:boolean=true;
}

app.component.css
====================
.active {
background-color: blue;
color: white;
}

.inactive {
background-color: grey;
color: white;
}
.c1
{
border: 5px solid green;
}

You might also like