删除降级 angular 2 组件属性周围的单引号会导致奇怪的行为

Removing single quotes around downgraded angular 2 component's properties causes strange behavior

我有一个降级的 angular 2 组件,它在 AngularJS 组件中工作正常,直到我删除组件第二个 属性.

周围的单引号

编辑:使用此组件的文件类型是 ng.jade。

这个有效:

user-score-component(
  [rating-score]="user.ratingScore"
  '[form-is-disabled]'="false"
  '(on-change)'="onRatingScoreChange($event)"
)

这不是:

user-score-component(
  [rating-score]="user.ratingScore"
  [form-is-disabled]="false"
  '(on-change)'="onRatingScoreChange($event)"
)

在第二个示例中,false 应用于 rating-score 并且 form-is-disabled 未定义。我可以在 form-is-disabled 周围留下单引号,但在对混合应用程序进行一些研究后,我无法弄清楚单引号在这里做什么。

为什么第二个 属性 (form-is-disabled) 而不是第一个 (rating-score) 需要它们?

Pug 的问题跟踪器 github 中提到了这一点:https://github.com/pugjs/pug/issues/2050

This is a difficult case to solve. For example:

input(foo='foo' [bar]='bar') //- since 'foo' [bar] is equivalent to
'foo'[bar] input(foo='foo'[bar]='bar') //- which is equivalent to
input(foo=('foo'[bar]='bar')) //- which is equivalent to
input(foo='bar')

input([foo]='foo' (bar)='bar') input(foo='foo'(bar)='bar')
input(foo=('foo'(bar)='bar')) //- 'foo'(bar)='bar → assigning to
rvalue ?

A work around you can use is quoting the attribute names:

input('[foo]'='foo' '[bar]'='bar') input('[foo]'='foo' '(bar)'='bar')

Since the bug is impossible to fix and a logical work around exists, I'm going to close this issue now.