【问题标题】:Angular2 - detect typos in templatesAngular2 - 检测模板中的拼写错误
【发布时间】:2016-10-13 13:55:15
【问题描述】:

检测 HTML 模板中的拼写错误的最佳方法是什么?

例子:

<h1>{{computer.systemTye}}</h1>

应该是

<h1>{{computer.systemType}}</h1>

理想情况下,我希望在编译期间在控制台中查看错误。或者在浏览器的调试控制台中。

我知道我可以使用 TestBed 类编写单元测试并使用类似的东西

de = fixture.debugElement.query(By.css('h1'));
el = de.nativeElement;

【问题讨论】:

    标签: debugging angular2-template string-interpolation misspelling


    【解决方案1】:

    使用默认运算符显示错误消息。例如:

    {{nae || 'error'}}
    

    参考文献

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-16
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-25
      • 1970-01-01
      相关资源
      最近更新 更多