Reputation: 21
I need to get window username(Enviorment.UserName) and domain name(Environment.DomianName) using angular. Is it possible using angularjs.
Upvotes: 0
Views: 3468
Reputation: 20634
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>
Upvotes: 1