📌 Set environment variable
This commit is contained in:
parent
75b6a0f45d
commit
7f4eb556d5
@ -1 +1,3 @@
|
||||
<h1>App works!</h1>
|
||||
<app-nav></app-nav>
|
||||
<router-outlet></router-outlet>
|
||||
<app-controls></app-controls>
|
||||
|
@ -1,7 +1,10 @@
|
||||
// Imports
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
|
||||
// Components
|
||||
import { AppComponent } from './app.component';
|
||||
import { HomeComponent } from './components/home/home.component';
|
||||
import { ControlsComponent } from './components/controls/controls.component';
|
||||
@ -16,7 +19,8 @@ import { NavComponent } from './components/nav/nav.component';
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule
|
||||
AppRoutingModule,
|
||||
HttpClientModule
|
||||
],
|
||||
providers: [],
|
||||
bootstrap: [AppComponent]
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { DataService } from 'src/app/services/data.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@ -7,9 +8,10 @@ import { Component, OnInit } from '@angular/core';
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
constructor(private data: DataService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.data.testConnection();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,15 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { environment } from 'src/environments/environment.prod';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DataService {
|
||||
|
||||
constructor() { }
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
testConnection() {
|
||||
this.http.get(`${environment.apiUrl}/query.php`).subscribe(() => {}, (err) => { throw new Error(err); });
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
export const environment = {
|
||||
production: true
|
||||
production: true,
|
||||
// The apiUrl should point to the api folder of the server-side code. E.g. https://jobbel.nl/music (No ending slash)
|
||||
apiUrl: ''
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user