Use the environments provided in angular.cli:
On environment.ts for development use
export const environment = {
production: false,
apiUrl: 'http://localhost:565565/api/v2'
};
On environment.prod.ts for production use:
export const environment = {
production: true,
apiUrl: 'https://www.data.com/api/v2'
};
Then depending on which environment you run your app the corresponding file will be used. If you run ng serve environment.ts will be used, if you run ng build --prod environment.prod.ts will be used.
Additionally you will need to import environment to your ts to use apiUrl
example in ts
import { environment } from './../environments/environment';
and use it as environment.apiUrl