【发布时间】:2018-12-18 17:25:18
【问题描述】:
示例:我正在使用 div 容器,当我运行代码时,我只得到什么
是开关的默认值。
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-test',
template: `
<div [ngSwitch]="toy_color">
<div *ngSwitchCase="'red'"> RED </div>
<div *ngSwitchCase="'blue'"> BLUE </div>
<div *ngSwitchCase="'Yellow'"> YEllOW </div>
<div *ngSwitchDefault> Pick Again </div>
</div>
`
styles: []
})
export class TestComponent implements OnInit {
public toy_color:"red";
constructor() { }
ngOnInit() { }
}
【问题讨论】:
-
尝试编辑您的帖子以澄清您的问题。
标签: angular6