Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update list-service docs with custom variables #6541

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions docs/en/UI/Angular/List-Service.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,50 @@ Bind `ListService` to ngx-datatable like this:
</ngx-datatable>
```

## Extending query with custom variables

You can extend the query parameter of the `ListService`'s `hookToQuery` method.

Firstly, you should pass your own type to `ListService` as shown below:

```typescript
constructor(public readonly list: ListService<BooksSearchParamsDto>) { }
```

Then update the `bookStreamCreator` constant like following:

```typescript
const bookStreamCreator = (query) => this.bookService.getList({...query, name: 'name here'});
```

You can also create your params object.

Define a variable like this:

```typescript
booksSearchParams = {} as BooksSearchParamsDto;
```

Update the `bookStreamCreator` constant:

```typescript
const bookStreamCreator = (query) => this.bookService.getList({...query, ...this.booksSearchParams});
```

Then you can place inputs to the HTML:

```html
<div class="form-group">
<input
class="form control"
placeholder="Name"
(keyup.enter)="list.get()"
[(ngModel)]="booksSearchParams.name"
/>
</div>
```

`ListService` emits the hookToQuery stream when you call the `this.list.get()` method.

## Usage with Observables

Expand Down