filmov
tv
Styling angular 2 components
Показать описание
Text version of the video
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Slides
Angular 2 Tutorial playlist
Angular 2 Text articles and slides
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
In this video we will discuss the different options available to apply styles to Angular Components.
The following are the different options available to style this "employee component"
table {
color: #369;
font-family: Arial, Helvetica, sans-serif;
font-size: large;
border-collapse: collapse;
}
td {
border: 1px solid black;
}
Advantages :
1. Visual Studio editor features (Intellisense, Code completion & formatting) are available.
2. Application maintenance is also easy as we only have to change the styles in one place if we need to change them for any reason.
Disadvantages :
1. The Stylesheet that contains the styles must be referenced for the component to be reused.
Option 2 : Specify the styles inline in the component HTML file as shown below.
[table style="color: #369;font-family: Arial, Helvetica, sans-serif;
font-size:large;border-collapse: collapse;"]
[tr]
[td style="border: 1px solid black;"]First Name[/td]
[td style="border: 1px solid black;"]{{firstName}}[/td]
[/tr]
[tr]
[td style="border: 1px solid black;"]Last Name[/td]
[td style="border: 1px solid black;"]{{lastName}}[/td]
[/tr]
[tr]
[td style="border: 1px solid black;"]Gender[/td]
[td style="border: 1px solid black;"]{{gender}}[/td]
[/tr]
[tr]
[td style="border: 1px solid black;"]Age[/td]
[td style="border: 1px solid black;"]{{age}}[/td]
[/tr]
[/table]
Advantages :
1. Visual Studio editor features (Intellisense, Code completion & formatting) are available.
2. Component can be easily reused as the styles are defined inline
3. Styles specified using this approach are local to the component and don't collide with styles used elsewhere in the application.
Disadvantages :
1. Application maintenance is difficult. For example, if we want to change the [td] border colour to red we have to change it in several places.
Option 3 : Specify the styles in the component html file using [style] tag as shown below
[style]
table {
color: #369;
font-family: Arial, Helvetica, sans-serif;
font-size: large;
border-collapse: collapse;
}
td {
border: 1px solid black;
}
[/style]
[table]
[tr]
[td]First Name[/td]
[td]{{firstName}}[/td]
[/tr]
[tr]
[td]Last Name[/td]
[td]{{lastName}}[/td]
[/tr]
[tr]
[td]Gender[/td]
[td]{{gender}}[/td]
[/tr]
[tr]
[td]Age[/td]
[td]{{age}}[/td]
[/tr]
[/table]
Advantages :
1. Component can be easily reused as the styles are defined inline with in the component itself
2. Application maintenance is also easy as we only have to change the styles in one place
3. Visual Studio editor features (Intellisense, Code completion & formatting) are available
4. Styles specified using this approach are local to the component and don't collide with styles used elsewhere in the application.
Option 4 : Specify the styles in the component TypeScript file using the @component decorator styles property as shown below. Notice the styles property takes an array of strings containing your styles.
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Slides
Angular 2 Tutorial playlist
Angular 2 Text articles and slides
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
In this video we will discuss the different options available to apply styles to Angular Components.
The following are the different options available to style this "employee component"
table {
color: #369;
font-family: Arial, Helvetica, sans-serif;
font-size: large;
border-collapse: collapse;
}
td {
border: 1px solid black;
}
Advantages :
1. Visual Studio editor features (Intellisense, Code completion & formatting) are available.
2. Application maintenance is also easy as we only have to change the styles in one place if we need to change them for any reason.
Disadvantages :
1. The Stylesheet that contains the styles must be referenced for the component to be reused.
Option 2 : Specify the styles inline in the component HTML file as shown below.
[table style="color: #369;font-family: Arial, Helvetica, sans-serif;
font-size:large;border-collapse: collapse;"]
[tr]
[td style="border: 1px solid black;"]First Name[/td]
[td style="border: 1px solid black;"]{{firstName}}[/td]
[/tr]
[tr]
[td style="border: 1px solid black;"]Last Name[/td]
[td style="border: 1px solid black;"]{{lastName}}[/td]
[/tr]
[tr]
[td style="border: 1px solid black;"]Gender[/td]
[td style="border: 1px solid black;"]{{gender}}[/td]
[/tr]
[tr]
[td style="border: 1px solid black;"]Age[/td]
[td style="border: 1px solid black;"]{{age}}[/td]
[/tr]
[/table]
Advantages :
1. Visual Studio editor features (Intellisense, Code completion & formatting) are available.
2. Component can be easily reused as the styles are defined inline
3. Styles specified using this approach are local to the component and don't collide with styles used elsewhere in the application.
Disadvantages :
1. Application maintenance is difficult. For example, if we want to change the [td] border colour to red we have to change it in several places.
Option 3 : Specify the styles in the component html file using [style] tag as shown below
[style]
table {
color: #369;
font-family: Arial, Helvetica, sans-serif;
font-size: large;
border-collapse: collapse;
}
td {
border: 1px solid black;
}
[/style]
[table]
[tr]
[td]First Name[/td]
[td]{{firstName}}[/td]
[/tr]
[tr]
[td]Last Name[/td]
[td]{{lastName}}[/td]
[/tr]
[tr]
[td]Gender[/td]
[td]{{gender}}[/td]
[/tr]
[tr]
[td]Age[/td]
[td]{{age}}[/td]
[/tr]
[/table]
Advantages :
1. Component can be easily reused as the styles are defined inline with in the component itself
2. Application maintenance is also easy as we only have to change the styles in one place
3. Visual Studio editor features (Intellisense, Code completion & formatting) are available
4. Styles specified using this approach are local to the component and don't collide with styles used elsewhere in the application.
Option 4 : Specify the styles in the component TypeScript file using the @component decorator styles property as shown below. Notice the styles property takes an array of strings containing your styles.
Комментарии