From 60dcdf20e57e02a4f917cb014a2df4d472a834a7 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Tue, 23 Jun 2020 11:24:54 +0300 Subject: [PATCH] feat(module-template): add a sample request to module's service --- .../lib/components/my-project-name.component.ts | 15 +++++---------- .../src/lib/my-project-name-routing.module.ts | 6 ++---- .../src/lib/services/my-project-name.service.ts | 13 +++++++++++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/templates/module/angular/projects/my-project-name/src/lib/components/my-project-name.component.ts b/templates/module/angular/projects/my-project-name/src/lib/components/my-project-name.component.ts index d2c11f230d..85ca370179 100644 --- a/templates/module/angular/projects/my-project-name/src/lib/components/my-project-name.component.ts +++ b/templates/module/angular/projects/my-project-name/src/lib/components/my-project-name.component.ts @@ -1,20 +1,15 @@ import { Component, OnInit } from '@angular/core'; +import { MyProjectNameService } from '../services/my-project-name.service'; @Component({ selector: 'lib-my-project-name', - template: ` -

- my-project-name works! -

- `, - styles: [ - ] + template: `

my-project-name works!

`, + styles: [], }) export class MyProjectNameComponent implements OnInit { - - constructor() { } + constructor(private service: MyProjectNameService) {} ngOnInit(): void { + this.service.sample().subscribe(console.log); } - } diff --git a/templates/module/angular/projects/my-project-name/src/lib/my-project-name-routing.module.ts b/templates/module/angular/projects/my-project-name/src/lib/my-project-name-routing.module.ts index 47b5683ac3..e698be1973 100644 --- a/templates/module/angular/projects/my-project-name/src/lib/my-project-name-routing.module.ts +++ b/templates/module/angular/projects/my-project-name/src/lib/my-project-name-routing.module.ts @@ -6,10 +6,8 @@ import { MyProjectNameComponent } from './components/my-project-name.component'; const routes: Routes = [ { path: '', - component: DynamicLayoutComponent, - children: [ - { path: '', pathMatch: 'full', component: MyProjectNameComponent }, - ], + pathMatch: 'full', + component: MyProjectNameComponent, }, ]; diff --git a/templates/module/angular/projects/my-project-name/src/lib/services/my-project-name.service.ts b/templates/module/angular/projects/my-project-name/src/lib/services/my-project-name.service.ts index a85ab345de..3dea468a45 100644 --- a/templates/module/angular/projects/my-project-name/src/lib/services/my-project-name.service.ts +++ b/templates/module/angular/projects/my-project-name/src/lib/services/my-project-name.service.ts @@ -1,9 +1,18 @@ import { Injectable } from '@angular/core'; +import { RestService } from '@abp/ng.core'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class MyProjectNameService { + apiName = 'MyProjectName'; - constructor() { } + constructor(private restService: RestService) {} + + sample() { + return this.restService.request( + { method: 'GET', url: '/api/MyProjectName/sample' }, + { apiName: this.apiName } + ); + } }