如何在angular 8中将变量声明为public const

时间:2019-07-15 18:32:36

标签: angular8

我想声明一个像public const SHIPMENT_MENU_ITEM='SHIPMENT';这样的常量变量,并通过引用const变量在我的html中使用。但是我做不到。我在这里想念的。

import { Component } from '@angular/core';

@Component({
  selector: 'app-header-bar',
  templateUrl: './header-bar.component.html',
  styleUrls: ['./header-bar.component.scss']
})


export class HeaderBarComponent {

  activeLink: String = 'SHIPMENT';

  constructor() {

  }

  onSelectNav(option) {
    this.activeLink = option;
  }

}

1 个答案:

答案 0 :(得分:0)

import { Component } from '@angular/core';

@Component({
  selector: 'app-header-bar',
  templateUrl: './header-bar.component.html',
  styleUrls: ['./header-bar.component.scss']
})


export class HeaderBarComponent {

public SHIPMENT_MENU_ITEM: String= SHIPMENT';

  activeLink: String = 'SHIPMENT';

  constructor() {

  }

  onSelectNav(option) {
    this.activeLink = option;
  }

}