Добавление переведенной строки в html (angular 6) со свойством объекта - PullRequest
0 голосов
/ 13 мая 2019

У меня есть файл myapp.component.ts, в котором у меня есть

import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { isNullOrUndefined } from 'util';
import { AuthenticationService } from '/services';
import * as _ from 'lodash';

@Component({
  selector: 'cd-myapp',
  templateUrl: './myapp.component.html',
  styleUrls: ['./myapp.component.scss']
   })
export class myAppComponent implements OnInit {
 @Input() car: Car;
constructor(
   private authenticationService: AuthenticationService) { }

ngOnInit() {
//my code
 }
}

У меня есть другой компонент, в котором у меня есть следующий файл в файле carhandler.component.ts:

import { Component, OnInit, Input, Output, EventEmitter } from 
'@angular/core';
 @Component({
   selector: 'app-carhandler',
   templateUrl: './carhandler.component.html',
   styleUrls: ['./carhandler.component.scss']
   })
 export class CarhandlerComponent implements OnInit {
 @Input() field: string;
 @Input() value: string;

 constructor() { }

 ngOnInit() {
 }}

В моем myapp.component.html я хотел бы добавить. Я попробовал это:

<app-carhandler [field]="Testing"
                          [value] = "'DESCRIPTION' | translate" +'-'+{{car.color}}>
      </app-carhandler >

Это не работает. Как мне решить эту проблему?

1 Ответ

1 голос
/ 13 мая 2019

Извините, у меня нет объяснения почему, но это работает так:

<app-carhandler [field]="Testing"
                      [value] = "(('DESCRIPTION' | translate) +'-'+ car.color)">
</app-carhandler >
...