Professional Documents
Culture Documents
Learning CSS
Learning Angular
Course Structure
(Application-wide, Component-
scoped, Special selectors)
A Refresher on CSS
Transitions & Animations
Becoming an Angular
(Transitions, Animations) Animations Pro
(Parallel Animations,
Keyframes, Lists, Routing, …)
The Basics about Angular
Animations
Application-wide Styles
Import in index.html
Import (via Webpack) in other Files
Component-scoped Styles
<h3></h3> <span>Hello!</span>
<div></div> <style>span {color: red}</style>
Hello!
Understanding Angular‘s Emulation
@Component({
Document Object Model (DOM) template: '<span>Hello!</span>',
styles: [`
<h3></h3> span {color: red}
<styles> `]
span[_ng-content-1] {color: red} })
</styles>
<my-component _ng-host-1>
<span _ng-content-1>Hello!</span> Understanding Angular‘s Emulation
</my-component>
Hello!
Understanding Angular‘s Emulation
@Component: {
…
encapsulation: ViewEncapsulation.Emulated Default
}
ViewEncapsulation.Native Uses native Shadow DOM
:host-context Style elements inside a component, depending on some condition set outside of it
/deep/ Apply styles not just to the elements in the template but also to child components
ngClass
[ngClass]="{class1: condition}"
[ngClass]="'class1 class2'"
[ngClass]="[class1 class2]"
Or use any expression (e.g. function call) which returns on of the valid values!
ngStyle
[ngStyle]="{'background-color': 'red'}"
[ngStyle]="{'width.px': 200}"
Or use any expression (e.g. function call) which returns on of the valid values!
Using CSS Animations
div {
transition: width 0.3s ease-out;
}
div {
animation: myAnimation 0.3s ease-out forwards;
}
keyframes myAnimation {
0% {
opacity: 0
}
100% {
opacity: 1
}
}
§ Value of a Property
<div>
Trigger § Return value of Method
<my-component>
§ Attached to DOM
Switches State
State (of the Element)
highlighted default
Defined by You!
loaded pending
Temporary
Transition Animate Animate
Style
Becoming an Angular Animations Pro
animate(300, style({}))
animate(300)
AppComponent
Component gets
removed and <router-outlet>
added here
ProjectsComponent UsersComponent