This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Inject } from '@angular/core'; | |
import { ApiService } from './api.service'; | |
import { Hashwords, IHashwords } from './libs.providers'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'], | |
}) | |
export class AppComponent { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { AppComponent } from './app.component'; | |
import { HashwordsProvider } from './libs.providers' | |
@NgModule({ | |
declarations: [AppComponent], | |
imports: [BrowserModule], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { InjectionToken, ValueProvider } from '@angular/core'; | |
interface IHashwords { | |
hash: (hash: string) => string[]; | |
hashStr: (hash: string) => string; | |
random: () => string[]; | |
randomStr: () => string; | |
} | |
const Hashwords: InjectionToken<IHashwords> = new InjectionToken<IHashwords>('hashwords'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Inject } from '@angular/core'; | |
import { ApiService } from './api.service'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'], | |
}) | |
export class AppComponent { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { AppComponent } from './app.component'; | |
import { ApiService } from 'app/api.service'; | |
import { FakeApiService } from './fake-api.service'; | |
@NgModule({ | |
declarations: [AppComponent], | |
imports: [BrowserModule], | |
providers: [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { ApiService } from 'app/api.service'; | |
@Injectable() | |
export class FakeApiService implements ApiService { | |
// Using implements to be sure FakeApiService has the same | |
// methods as original ApiService | |
constructor() { } | |
serviceCall() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { ApiService } from './api.service'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'], | |
}) | |
export class AppComponent { | |
title = 'app'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
@Injectable() | |
export class ApiService { | |
constructor() { } | |
serviceCall() { | |
console.log('I am api service instance call!'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApiService } from 'app/api.service'; | |
@NgModule({ | |
declarations: [AppComponent], | |
imports: [BrowserModule], | |
providers: [ | |
{ provide: ApiService, useClass: ApiService } | |
], | |
bootstrap: [AppComponent] | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApiService } from './api.service'; | |
@NgModule({ | |
declarations: [AppComponent], | |
imports: [BrowserModule], | |
providers: [ | |
ApiService | |
], | |
bootstrap: [AppComponent] | |
}) |
NewerOlder