angular / angular/components

feat(Dialog): Allow data to be a signal

Đang mở
#28,848 2 bình luận 11 reaction 0 người được giao Xem trên GitHub
area: material/dialog feature P4
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

### Feature Description

Currently, to access data inside a material component, and treat it as a signal, we have to inject MAT_DIALOG_DATA and get the data like this:

```
import { MAT_DIALOG_DATA } from '@angular/components/dialog';

data =signal( inject(MAT_DIALOG_DATA)) // create signal from input data

ngOnInit() {
// Do something with the data
}
```

Proposal:

Create a new function that injects MAT_DIALOG_DATA for us, and returns the injected data as a signal:

```
import { dialogData } from '@angular/material/dialog' // new function

data = dialogData(); // data is now a signal

doSomething = effect( () => dosomethingWithhdata( this.data());
```

### Use Case

Having data inputs for dialogs handled in the same way as regular components, and having the inputs available as signals without needing the boilerplate code we currently need to do.

Having inputs as signals also lets us avoid using ngOnInit and constructors because it lets us use effect() to initiate actions

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách theo dõi đường dẫn injection hiện có của MAT_DIALOG_DATA trong package dialog của Angular Material và xem xét cách các public API được expose từ @angular/material/dialog. Xác định signal API và hành vi mong đợi của nó dựa trên proposal, sau đó bổ sung coverage cho việc đọc dữ liệu dialog thông qua function mới; công việc được xem là hoàn tất khi use case được document hoạt động mà không cần boilerplate inject-and-signal thủ công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
frontend
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.