使用angular.js窗口获取用户名和域名 [英] Get window username and domain name using angular.js

查看:189
本文介绍了使用angular.js窗口获取用户名和域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要得到窗口的用户名(Enviorment.UserName),并采用了棱角分明的域名(Environment.DomianName)。难道使用angularjs可能。

I need to get window username(Enviorment.UserName) and domain name(Environment.DomianName) using angular. Is it possible using angularjs.

推荐答案

AngularJS是一个客户端应用程序,只访问了在浏览器的 delcared变量窗口目的。环境对象是什么,只是在默认情况下在服务器上访问。根据您要创建什么类型的应用程序,你可以用剃刀或ASP语言做这样的事情:

AngularJS is a client side application and only has access to the variables that are delcared in the browser's window object. The Environment object is something that is only accessible on the server by default. Depending on what type of application you are creating, you can use Razor or ASP language to do something like:

// c#
public static string UserDomainName { get; }

// cshtml / aspx (JavaScript)
<script>
  // add to global window object (not recommended, but will work)
  window.yourUserNameVariable = @UserDomainName; // or <%=UserDomainName %> if asp
</script>

这篇关于使用angular.js窗口获取用户名和域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆