1
我已经完成了自定义枚举(请参阅代码),并且希望重复使用以FOO
和BAR
声明的常量,而不必在types
阵列中再次写入常量的值。我会怎么做呢?在同一个角度模块中重复使用常量
var myApp = angular.module('app');
myApp.constant('MyEnum', {
FOO: "foo",
BAR: "bar",
types: [
{id: 0, value: 'foo', label:"Foo"},
{id: 1, value: 'bar', label:"Bar"}
]
});
我愿做这样的事情types
数组中:
types: [
{id: 0, value: this.FOO, label:"Foo"},
{id: 1, value: this.BAR, label:"Bar"}
]
做起来像这给了我的错误。有什么建议么?
谢谢!在中间变量中使用两个下划线是否很常见? – John
@John他们通常意味着“私人”变量。 –