Notice: file_put_contents(): Write of 16897 bytes failed with errno=28 No space left on device in /var/www/tgoop/post.php on line 50
Frontender Libs - обзор библиотек JS / CSS@sWebDev P.3171
SWEBDEV Telegram 3171
Инъекции зависимостей через глобальную функцию inject()

Функция inject() в Angular позволяет инъектировать зависимости непосредственно в тело функции. Это альтернатива стандартному подходу через конструкторы.

Пример использования:
import { inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';

export class DataService {
private http = inject(HttpClient);

fetchData() {
return this.http.get('/api/data');
}
}

inject() вызывает инъекцию Angular для получения нужной зависимости. Ее можно использовать в теле класса, а не только в параметрах конструктора.

Пример тестирования:
import { inject } from '@angular/core';
import { HttpTestingController } from '@angular/common/http/testing';

describe('DataService', () => {
let httpMock = inject(HttpTestingController);

it('should fetch data', () => {
// Логика теста
});
});

👉 @sWebDev
👍7🔥1



tgoop.com/sWebDev/3171
Create:
Last Update:

Инъекции зависимостей через глобальную функцию inject()

Функция inject() в Angular позволяет инъектировать зависимости непосредственно в тело функции. Это альтернатива стандартному подходу через конструкторы.

Пример использования:

import { inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';

export class DataService {
private http = inject(HttpClient);

fetchData() {
return this.http.get('/api/data');
}
}

inject() вызывает инъекцию Angular для получения нужной зависимости. Ее можно использовать в теле класса, а не только в параметрах конструктора.

Пример тестирования:
import { inject } from '@angular/core';
import { HttpTestingController } from '@angular/common/http/testing';

describe('DataService', () => {
let httpMock = inject(HttpTestingController);

it('should fetch data', () => {
// Логика теста
});
});

👉 @sWebDev

BY Frontender Libs - обзор библиотек JS / CSS




Share with your friend now:
tgoop.com/sWebDev/3171

View MORE
Open in Telegram


Telegram News

Date: |

The best encrypted messaging apps The public channel had more than 109,000 subscribers, Judge Hui said. Ng had the power to remove or amend the messages in the channel, but he “allowed them to exist.” So far, more than a dozen different members have contributed to the group, posting voice notes of themselves screaming, yelling, groaning, and wailing in various pitches and rhythms. Add the logo from your device. Adjust the visible area of your image. Congratulations! Now your Telegram channel has a face Click “Save”.! For crypto enthusiasts, there was the “gm” app, a self-described “meme app” which only allowed users to greet each other with “gm,” or “good morning,” a common acronym thrown around on Crypto Twitter and Discord. But the gm app was shut down back in September after a hacker reportedly gained access to user data.
from us


Telegram Frontender Libs - обзор библиотек JS / CSS
FROM American