> For the complete documentation index, see [llms.txt](https://odilbeks-organization.gitbook.io/untitled/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://odilbeks-organization.gitbook.io/untitled/frontend-features.md).

# Frontend features

### Equals

1. Angular \*ngIf & \[ngIf]

```
<ng-container *ngIf="expression;else template"></ng-container>
// Equals
<ng-template [ngIf]="expression" [ngIfElse]="template"></ng-template>

<ng-template #template></ng-template>
```

2. &#x20;\*ngFor & ngFor

```
// Some code
<ng-container *ngFor="let item of items"></ng-container>
<ng-template ngFor [ngForOf]="items" let-item></ng-template>
```

### Good code

1. Handle Input

```
// Some code

<input (input)="handleClick($event) />

// Bad code
handleInput(event: any) {
  console.log(event.target.value);
}

// Good code
handleInput(event: Event) {
  const { value } = event.target as HTMLInputElement;
  console.log(value);
}
```

2. Generic type

```
// Bad code
export interface UserRequest {
    ...
    role: number;
}
export interface UserResponse {
    ...
    role: Role;
}
export interface Role {
    ...
}

// Good code
export interface IUser<TRole> {
    ...
    role: TRole;
}
export interface UserRequest extends IUser<number> {
    ...
}
export interface UserResponse extends IUser<Role> {
    ...
}
export interface Role {
    ...
}
```

3. Destructuring

```
export interface Rectangle {
    x: number;
    y: number;
    height: number;
    weight: number;
}

const rect: Rectangle = { x: 0, y: 10, width: 15, height: 20 };

// Not Bad
console.log(rect.x, rect.y, rect.width, rect.height); // 0,10,15,20

// Better code with Destructuring assignment
var {x, y, width, height} = rect;
console.log(x, y, width, height); // 0,10,15,20

```

### Angular 16

1. inject

```
// Old style
constructor(private someService: SomeService) {
...
}

// New style
someService = inject(SomeService);
```

## Do you know?

1. Ng style

```
// Ng Style
[ngStyle]="{'font-size.px: 20}}"
```

2. Margin in Css

> When two margins are touching each other vertically, they are collapsed. When two margins touch horizontally, they do not collapse.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://odilbeks-organization.gitbook.io/untitled/frontend-features.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
