0

我在严格模式下使用 Angular,我认为因为这是标准的方式,所以最好使用它并习惯它。我面临的问题是我的原始应用程序是 Angular 8 我将其更新为 Angular 13。我的原始应用程序具有绑定到对象的搜索区域,因为该对象具有未初始化的变量(null)文本框显示为空,例如:

export class SearchOptions{
  numberValves:number;// non strict mode I don't need to initialize it
}

...

         searchOptions = new SearchOptions();

因为“numberValves”没有初始化,我可以将它绑定到一个输入并且输入将为空,这对于初始页面加载来说是完美的。

  number of valves |        | --> supose it is an html label and input

现在使用严格模式我需要初始化对象

 export class SearchOptions{
  numberValves:number = -1;// strict mode I do need to initialize it
}


     number of valves |   -1   | --> -1 appears it is not possible to show empty input now "simply"

如何处理?

4

0 回答 0