# Angular Basics --- #### Motivation * State Change ⟹ UI Change * Viel js * Viel overhead * js 😕 ---- #### Frameworks    --- #### Konfiguration
package.json
Scripts, dependencies
tsconfig.json
TypeScript-Compiler
angular.json
Angular
app.config.ts
App
In den Übungen ✅
---- #### `index.html` ```angular181html ...
``` `+ *.ts $\rightarrow$ Compiler $\rightarrow$` ```html
``` ---- #### `app-root`  ```typescript import {Component} from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrl: './app.component.css' }) export class AppComponent { // code goes here } ``` --- #### String Interpolation ```typescript import {Component} from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrl: './app.component.css' }) export class AppComponent { displayedVariable = signal(42); valueJustForTs = 'ok'; } ``` ```angular181html
{{ displayedVariable() }}
==>
42
``` ```typescript this.displayedVariable.set(3) ==>
3
``` --- #### Event Binding ```html
``` ```typescript @Component({ ... }) export class AppComponent { n = signal(42); foo() { if (this.n() < 100) this.n.set(this.n() + 1); else this.n.update(value => value - 1) console.log(this.n()) } } ``` ---- #### Events ```angular181html (click)='foo()' (dblclick)='foo()' (focus)='foo()' (blur)='foo()' (keydown.enter)='foo()' (mouseenter)='foo($event)' (keydown)='foo($event)' ``` `$event` enthält Informationen über das Event * Welche Taste * Input * Maustaste * Koordinaten * ... --- #### Property Binding ```typescript url = signal('some-url'); ``` ```html
```
```html
``` ```html
```
property
vs
[property]
🤔
Intellisense 👍
---- #### Styling ```angular181html
Error!
``` ```text if error(): give the
class ``` ```html
Error!
``` mehrere ```angular181html
Error!
``` ```text if error(): give the
class if aria(): give the
class ``` --- #### Two-Way-Binding
```typescript age = signal(16); ``` ```angular181html
``` keine `()`, wir wollen nicht nur den Wert --- #### Cheat Sheet ```angular181html {{ interpolation() }}
Event Binding
Property Binding
```