簡體   English   中英

為angularjs中的常量定義函數

[英]define function for constants in angularjs

我正在嘗試定義一個函數來保持常數,但不起作用

(function(){
'use strict';

angular
    .module('app')
    .constant('config1', config1)
    .constant('config2', 
        (function(){
            return {
                VERSION: 2
            }
        }())
    );

function config1() {
    return {
        VERSION: '1'
    }
};

})();

console.log(config1.VERSION); //未定義

console.log(config2.VERSION); // 2

我認為您錯過了config1 **()**。VERSION;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM