Browse Source

feat(module-template): add a sample request to module's service

pull/4457/head
mehmet-erim 6 years ago
parent
commit
60dcdf20e5
  1. 15
      templates/module/angular/projects/my-project-name/src/lib/components/my-project-name.component.ts
  2. 6
      templates/module/angular/projects/my-project-name/src/lib/my-project-name-routing.module.ts
  3. 13
      templates/module/angular/projects/my-project-name/src/lib/services/my-project-name.service.ts

15
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 { Component, OnInit } from '@angular/core';
import { MyProjectNameService } from '../services/my-project-name.service';
@Component({ @Component({
selector: 'lib-my-project-name', selector: 'lib-my-project-name',
template: ` template: ` <p>my-project-name works!</p> `,
<p> styles: [],
my-project-name works!
</p>
`,
styles: [
]
}) })
export class MyProjectNameComponent implements OnInit { export class MyProjectNameComponent implements OnInit {
constructor(private service: MyProjectNameService) {}
constructor() { }
ngOnInit(): void { ngOnInit(): void {
this.service.sample().subscribe(console.log);
} }
} }

6
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 = [ const routes: Routes = [
{ {
path: '', path: '',
component: DynamicLayoutComponent, pathMatch: 'full',
children: [ component: MyProjectNameComponent,
{ path: '', pathMatch: 'full', component: MyProjectNameComponent },
],
}, },
]; ];

13
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 { Injectable } from '@angular/core';
import { RestService } from '@abp/ng.core';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root',
}) })
export class MyProjectNameService { export class MyProjectNameService {
apiName = 'MyProjectName';
constructor() { } constructor(private restService: RestService) {}
sample() {
return this.restService.request<void, any>(
{ method: 'GET', url: '/api/MyProjectName/sample' },
{ apiName: this.apiName }
);
}
} }

Loading…
Cancel
Save