在 html (angular 6) 中附加已翻译的字符串和对象的 属性
Appending a translated string in html (angular 6) with a property of an object
我有一个 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 >
没用。我该如何解决这个问题?
抱歉,我无法解释原因,但它是这样工作的:
<app-carhandler [field]="Testing"
[value] = "(('DESCRIPTION' | translate) +'-'+ car.color)">
</app-carhandler >
我有一个 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 >
没用。我该如何解决这个问题?
抱歉,我无法解释原因,但它是这样工作的:
<app-carhandler [field]="Testing"
[value] = "(('DESCRIPTION' | translate) +'-'+ car.color)">
</app-carhandler >