`EventEmitter` is a function to emit custom events.
cockpit.component.ts
```ts
import { Component, OnInit, EventEmitter, Output, } from '@angular/core';
@Component({
selector: 'app-cockpit',
templateUrl: './cockpit.component.html',
styleUrls: ['./cockpit.component.css']
})
export class CockpitComponent implements OnInit {
@Output() serverCreated = new EventEmitter<{serverName: string, serverContent: string}>();
@Output('bpCreated') blueprintCreated = new EventEmitter<{serverName: string, serverContent: string}>();
newServerName = '';
newServerContent = '';
constructor() { }
ngOnInit() {
}
onAddServer(nameInput: HTMLInputElement) {
this.serverCreated.emit({
serverName: this.newServerName,
serverContent: this.newServerContent
});
}
onAddBlueprint(nameInput: HTMLInputElement) {
this.blueprintCreated.emit({
serverName: newServerName,
serverContent: this.newServerContent
});
}
}
```
app.component.html
```html
<divclass="container">
<app-cockpit
(serverCreated)="onServerAdded($event)"
(blueprintCreated)="onBlueprintAdded($event)"
></app-cockpit>
<hr>
<divclass="row">
<divclass="col-xs-12">
<app-server-element
*ngFor="let serverElement of serverElements"
[srvElement]="serverElement">
</app-server-element>
</div>
</div>
</div>
```
> Cockpit is the parent element, so it sends out data or event, thats why the `@Output` decorator.
>
> ServerElement is the Child element, so it receive data in, thats why the `@Input` decorator
## Locale Reference
The locale references can put on any element in the html template.
```html
#nameOfTheReference
```
It holds the whole element, not only the values. This can be used **only** in the *template***not** in the *TS-file*. But it can be passed as an argument in the TS-file.
## @ViewChild
It can also be able to get data with the `@ViewChild` decorator.
> `serverContentInput` is the name of the locale reference in the html template.
Twho-way-binding is not anymore required.
> It is not adviced to set a value with this method.
## ng-content
This directive can be used to project the content of the DOM, which would be lost when placed in the opening and closing tags of the element in the template. This behavior is called `hoock`.
## lifecycle
ngOnInit is a lifecycle hook.
The application can hook into this hooks to execute some actions.