angularjs - Get AngularJS constacts
问题描述
I want to get the constant "ClientID" value from
<script>
angular.module("myModule", []).constant("appSetting",
{
appEnvironment: 'INTRANET',
ClientID: '0663555953',
Scope: 'Level1',
}
);
</script>
located in startPage.aspx
to another js file. i've tried this
<script>
var ClientID = angular.module("myModule", []).constant("appSetting").(ClientID);
function myFucntion()
{
console.log(ClientID);
}
<script>
解决方案
您可以将常量注入控制器:
angular.module('myModule').controller('someController',['$scope','appSetting',
function($scope, appSetting){
console.log(appSetting.ClientID);
}
]);
推荐阅读
- c# - 继承数据注解 StringLengthAttribute
- flutter - 如何在左侧对齐 TextFormField
- python - 从现有的两个不同长度的数据框中填充新列
- javascript - 从 jQuery click() 事件中的父函数访问变量(Word 插件)
- java - Android kotlin - BottomNavigationView 在 TimerTask 中使用 BadgeView
- mysql - SQL 检查表是否存在然后创建表并插入到同一个查询中
- c# - 我想每 1 秒获取一次 CPU 使用率(所有核心)
- python - Python SQLite 提供绑定
- r - 使用临时文件夹通过 testthat 运行测试
- c - 为什么编译器无法检测到我的代码中的减号?