Skip to content

Commit d785fe5

Browse files
committed
angular study file add
1 parent d3bab13 commit d785fe5

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

angular/angular-quick-start3/src/app/a/a.component.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { OneService } from './../one.service';
2-
import { Component, OnInit } from '@angular/core';
2+
import { Component, OnInit, Inject } from '@angular/core';
33

44
@Component({
55
selector: 'app-a',
@@ -8,8 +8,9 @@ import { Component, OnInit } from '@angular/core';
88
})
99
export class AComponent implements OnInit {
1010

11-
constructor(private one: OneService) {
11+
constructor(private one: OneService, @Inject('apiUrl') private apiUrl: string) {
1212
console.log(one.name);
13+
console.log(apiUrl);
1314
}
1415

1516
ngOnInit() {

angular/angular-quick-start3/src/app/app.module.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ import { BComponent } from './b/b.component';
1818
BrowserModule
1919
],
2020
providers: [
21-
OneService
21+
{
22+
provide: 'one',
23+
useClass: OneService
24+
},
25+
{
26+
provide : 'apiUrl',
27+
useValue : 'test'
28+
}
2229
],
2330
bootstrap: [AppComponent]
2431
})

0 commit comments

Comments
 (0)