Commit migrated from dotnet/aspnetcore@50833cc8f9
This commit is contained in:
Isaac Levin 2019-06-07 10:03:27 -04:00
Родитель 9b14eb49b3
Коммит 7ea89e99d8
4 изменённых файлов: 35 добавлений и 9 удалений

Просмотреть файл

@ -1,5 +1,5 @@
{
"name": "Company.WebApplication1",
"name": "company.webapplication1",
"version": "0.0.0",
"scripts": {
"ng": "ng",

Просмотреть файл

@ -9,6 +9,11 @@ import { NavMenuComponent } from './nav-menu/nav-menu.component';
import { HomeComponent } from './home/home.component';
import { CounterComponent } from './counter/counter.component';
import { FetchDataComponent } from './fetch-data/fetch-data.component';
////#if (IndividualLocalAuth)
import { ApiAuthorizationModule } from 'src/api-authorization/api-authorization.module';
import { AuthorizeGuard } from 'src/api-authorization/authorize.guard';
import { AuthorizeInterceptor } from 'src/api-authorization/authorize.interceptor';
////#endif
@NgModule({
declarations: [
@ -22,13 +27,26 @@ import { FetchDataComponent } from './fetch-data/fetch-data.component';
BrowserModule.withServerTransition({ appId: 'ng-cli-universal' }),
HttpClientModule,
FormsModule,
////#if (IndividualLocalAuth)
ApiAuthorizationModule,
////#endif
RouterModule.forRoot([
{ path: '', component: HomeComponent, pathMatch: 'full' },
{ path: 'counter', component: CounterComponent },
////#if (IndividualLocalAuth)
{ path: 'fetch-data', component: FetchDataComponent, canActivate: [AuthorizeGuard] },
////#else
{ path: 'fetch-data', component: FetchDataComponent },
////#endif
])
],
////#if (IndividualLocalAuth)
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: AuthorizeInterceptor, multi: true }
],
////#else
providers: [],
////#endif
bootstrap: [AppComponent]
})
export class AppModule { }

Просмотреть файл

@ -1,17 +1,22 @@
import { Component, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Component, Inject } from "@angular/core";
import { HttpClient } from "@angular/common/http";
@Component({
selector: 'app-fetch-data',
templateUrl: './fetch-data.component.html'
selector: "app-fetch-data",
templateUrl: "./fetch-data.component.html"
})
export class FetchDataComponent {
public forecasts: WeatherForecast[];
constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string) {
http.get<WeatherForecast[]>(baseUrl + 'api/Company.WebApplication1Data/WeatherForecasts').subscribe(result => {
this.forecasts = result;
}, error => console.error(error));
constructor(http: HttpClient, @Inject("BASE_URL") baseUrl: string) {
http
.get<WeatherForecast[]>(baseUrl + "api/SampleData/WeatherForecasts")
.subscribe(
result => {
this.forecasts = result;
},
error => console.error(error)
);
}
}

Просмотреть файл

@ -19,6 +19,9 @@
class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse"
[ngClass]="{ show: isExpanded }"
>
<!--#if (IndividualLocalAuth) -->
<app-login-menu></app-login-menu>
<!--#endif -->
<ul class="navbar-nav flex-grow">
<li
class="nav-item"