如何在ngModel中禁用更改值

时间:2018-06-21 11:07:29

标签: angular unit-testing typescript

我在Angular 5中拥有组件-尝试构建单元测试,以检查何时禁用它,否则无法为组件模型设置值。 而且我不知道为什么-仍然可以更改。

  [(ngModel)]="value"
  [attr.disabled]="disabled ? 'disabled' : null"

测试看起来像这样-这给了我错误

    it("DISABLED", async(() => {
    component.disabled = true;
    component.value = 'testtesttest';      
    fixture.detectChanges();
    const htmlInputComponent: HTMLElement = fixture.nativeElement;
    const inputValue = htmlInputComponent.querySelector('input').value;
    expect(inputValue).toBeFalsy();
}));

试图在ngOnChange中添加一些规则-但它仍然会改变值。

1 个答案:

答案 0 :(得分:1)

尝试-

def coin_profile(request, username, coin):
    test = Transaction.objects.filter(user__username=username, coin=coin)