This file contains 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
//Use the InjectionToken for the mapsConfig, this can be later used to inject it with DI | |
export const MapsConfig = new InjectionToken<IMapsConfig>('MAPS_CONFIG'); | |
@Injectable({ | |
providedIn: MapModule | |
}) | |
export class MapService { | |
private _key: string; | |
constructor( |
This file contains 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
export class MapModule { | |
//create a static function with the mapConfig as a parameter | |
static forRoot(mapConfig: IMapsConfig): ModuleWithProviders { | |
return { | |
ngModule: MapModule, | |
//We provide a MapsConfig InjectionToken, which we later can use in our service to use | |
providers: [ {provide: MapsConfig, useValue: mapConfig} ] | |
}; | |
} | |
} |
This file contains 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
export class MapModule { | |
//create a static function with the mapConfig as a parameter | |
static forRoot(mapConfig: IMapsConfig): ModuleWithProviders { | |
return { | |
ngModule: MapModule, | |
//We provide a MapsConfig InjectionToken, which we later can use in our service to use | |
providers: [ {provide: MapsConfig, useValue: mapConfig} ] | |
}; | |
} | |
} |
This file contains 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
<input type="text" /> | |
<div tabindex="0"></div> | |
<div tabindex="0"></div> | |
<input type="text" /> |
This file contains 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
public class AuthenticationHelper : IAuthenticationHelper | |
{ | |
static string ApplicationName = "APPLICATIONNAME"; | |
static string RefreshToken = "YOURREFRESHTOKEN"; | |
public DriveService Authenticate() | |
{ | |
var token = new TokenResponse | |
{ | |
RefreshToken = RefreshToken |
This file contains 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
this.blogs.forEach((blog: any) => { delete blog.__typename; }); |
This file contains 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
// delegate to your own implementation | |
spyOn(MoviesComponent, 'getMovies').and.callFake(() => {}); | |
//delegate to your own implementation with an argument | |
spyOn(MoviesComponent, 'getMovies').withArgs('').and.callFake(() => {}); | |
//return a specific value 'false' | |
spyon(MoviesComponent, 'getMovies').and.returnValue({movies: ['terminator', 'titanic', 'avatar']}}); | |
//delegate to the actual implementation |
This file contains 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
export class MoviesComponent { | |
constructor() {} | |
getMovies(): void { | |
this.http.get('http://example.com/movies.json').toPromise().then((response) => { | |
console.log(response); | |
}); | |
} |
This file contains 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
<label for="my-lovely-checkbox">Some label text</label> | |
<input type="checkbox" id="my-lovely-checkbox" /> |
This file contains 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
var parents = await _context.Set<Parent>() | |
.Include(m => (m as Child1).Property1) | |
Include(m => (m as Child2).Property1) | |
.ToListAsync(); |