How to use environment variables in your Angular application

If you develop a website that uses multiple environments such as development, staging and production you probably have a configuration file of sorts to handle things like database settings, mail server credentials, and so on for your backend system. But how do you handle such variables in the front-end? Specifically, in an AngularJS App? For instance, you might have a seperate API you’re talking to for your content, which has a different location locally, than on your production server.