小编Vuk*_*Dju的帖子

以编程方式在angular5 ng-select中设置所选值

我正在使用angular5 ng-select组件:https : //github.com/ng-select/ng-select, 并尝试在首次加载容器组件时(以编程方式)设置选定值(在模型)。我没有找到任何相关属性或每个项目的isSelected属性。这是我的代码(已过滤):HTML:

<ng-select [items]="filter.values"  bindLabel="text" bindValue="id" class="input-md" [(ngModel)]="filter.selectedValue"></ng-select>
Run Code Online (Sandbox Code Playgroud)

模型:

export class FilterData
{
    Name : string;
    FormattedName : string;
    values : Filter[];
    selectedValue : Filter = null;
    constructor(filterData : FilterData)
    {
        this.Name = filterData.Name;
        this.values = filterData.values;
        this.selectedValue = typeof filterData.selectedValue == "undefined" ? null : filterData.selectedValue;
    }
}

export class Filter 
{
    public id: number;
    public text: string;
}
Run Code Online (Sandbox Code Playgroud)

selectedvalue selecteditem angular-ngselect angular5

1
推荐指数
1
解决办法
6679
查看次数

如何在nest.js TypeORM中编写日期小于或等于某个值的where条件?

我正在使用 Nest.js 和 TypeORM。我需要进行一个查询,返回表中的所有行,其中facility_id 等于某个值,并且date 小于或等于(<=) 某个日期值。

我阅读了有关Nest.js的文档,但找不到正确的方法。

另外,我阅读了typeORM的官方 GitHub 文档。

这是我的代码。如果可以使用 EntityRepository 中的 find 方法来完成,那就太好了

import { DeleteResult, EntityRepository, Repository, UpdateResult } from "typeorm";
import { Reservations} from "src/Entities/reservations.entity";
import { Facility} from "src/Entities/facility.entity";
import { PaginationParams } from "src/pagination.model";
import { LessThanOrEqual } from "typeorm";



@EntityRepository(Reservation)
export class ReservationRepository extends Repository<Reservation> {

    
    
    async findByFacility(ustanovaId, paginationParams, dateParams): Promise<Reservation[]> {

        return await this.find({where: { termin: LessThanOrEqual(new Date(2021, 0, 1))},
             relations: ["users", "facility"],
             take: paginationParams.limit,
             skip: paginationParams.offset,
             order: { …
Run Code Online (Sandbox Code Playgroud)

typeorm nestjs

0
推荐指数
1
解决办法
7815
查看次数