Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在角度变量中使用=_Html_Angular - Fatal编程技术网

Html 如何在角度变量中使用=

Html 如何在角度变量中使用=,html,angular,Html,Angular,我需要这样做: <app-popover #popName texto="{{'texto'='errorName1' | translate}}" ></app-popover> <app-popover #popName texto="{{'texto'='errorName2' | translate}}" ></app-popover> <app-popover #popName texto="{{'texto'='errorName

我需要这样做:

<app-popover #popName texto="{{'texto'='errorName1' | translate}}" ></app-popover>
<app-popover #popName texto="{{'texto'='errorName2' | translate}}" ></app-popover>
<app-popover #popName texto="{{'texto'='errorName3' | translate}}" ></app-popover>

但它返回一个错误

我必须将其发送到另一个html,在那里打印文本,但由于代码被重用,并且我使用的是一个转换器,因此我必须能够使用不同的变量名:

<ng-template #popContent let-greeting="greeting">{{"texto"}}!</ng-template>
{{“texto”}!

为什么不在TS/JS中捕捉它并使用switchcase

switch (this.texto) {
  case this.error1:
    this.texto = this.error1;
    break;
  case this.error2:
    this.texto = this.error2;
    break;
}

另一种选择是使用if/else语句。

对不起,我认为你的问题有点不清楚。 如果我猜对了你想做什么,你应该: 1.将属性绑定到错误,如[textto]=error 2.通过应用程序popover组件中的@input接受输入 3.直接在app popover组件中翻译文本


我认为这种方法更清晰,也更易于重用,因为如果出现3个以上的错误,您可以只使用数组和循环,而不必返回。我认为这种方法也应该消除您的错误,因为我认为行texto=“{{'texto'='errorName1'| translate}}”太容易出错。

这些组件是兄弟还是父子?