Different environments for my application

Hi, I have been trying to figure it out. How to is it possible to build different environments for my application.

When In production I want the app to hit one URL and when development the app should hit other URL.

Thank you for your.

Is this a data access URL within your app ?

It would be nice if Ionic could support a similar sort of workflow to, say, Ruby on Rails whereby we can nominate a development, test and production environments with the associated data pointers and global variables etc.

But in the interim, I manage to hack through this via checking the ionic.Platform.device() object to see if I am running in a web browser (development) or the device (production). An empty object being returned means we are running in a browser (i.e. during development):

if (angular.equals({}, ionic.Platform.device())) {
  // development declarations go here 
} else {
  // production declarations go here
1 Like

That’s actually a pretty nice hack. It would be nice if they could support enviorments right from the start.

Thank you.

I check the $host in the $location where the app is running on. Depending on the $host I change the Url I use in my code. If the app is running on a desktop browser there is a $host. Like in my development environment its localhost from the URL http://localhost/appname.
If the app is running on a mobile device there is no $host. So I use a default Url for where a mobile app is pointing to and overruled by the $host if there is one in $location. Hope this helps…

1 Like

Thank you, I think both solutions are pretty great, that’s what I needed.