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 { BehaviorSubject, Observable } from 'rxjs'; | |
| @Injectable({ | |
| providedIn: 'root' | |
| }) | |
| export class StorageService { | |
| private storeDataSubjects: Map<string, BehaviorSubject<any>> = new Map(); |
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({ | |
| providedIn: 'root' | |
| }) | |
| export class StorageService { | |
| constructor() { } |
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
| <button (click)=”deleteItem()”>Delete item</button> |
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
| // we are now also importing SweetAlertOptions in our decorator | |
| import Swal, {SweetAlertOptions} from 'sweetalert2'; | |
| // Confirmable is now a factory function, with an optional parameter object | |
| export function Confirmable(options?: SweetAlertOptions) { | |
| // our factory function will return our actual decorator function, but now we have | |
| // an actual options object to configure our alert box :) | |
| return (target: Object, propertyKey: string, descriptor: PropertyDescriptor) => { | |
| // the usual, caching the original implementation |
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, OnInit } from '@angular/core'; | |
| import Swal from 'sweetalert2'; | |
| @Component({ | |
| selector: 'example-component', | |
| template: ‘Swal component!' | |
| }) | |
| export class ExampleComponent implements OnInit { | |
| constructor() {} |
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 { MyService } from './my-service'; | |
| @Component({ | |
| selector: 'example-component', | |
| template: 'More component example!' | |
| }) | |
| export class ExampleComponent { | |
| constructor(myService: MyService) { | |
| console.log(myService); // MyService |
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, HostListener } from '@angular/core'; | |
| @Component({ | |
| selector: 'example-component', | |
| template: ‘Hey another component!' | |
| }) | |
| export class ExampleComponent { | |
| @HostListener('click', ['$event']) | |
| onHostClick(event: Event) { | |
| // clicked, `event` available |
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
| <example-component | |
| [exampleProperty]="exampleData"> | |
| </example-component> |
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 { NgModule } from '@angular/core'; | |
| @NgModule({ | |
| imports: [], | |
| declarations: [], | |
| }) | |
| export class ExampleModule { | |
| constructor() { | |
| console.log('Hi, I am an example module!'); | |
| } |
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'; | |
| @Component({ | |
| selector: 'example-component', | |
| template: '<div>Hello world! I'm an example component!</div>', | |
| }) | |
| export class ExampleComponent { | |
| constructor() { | |
| console.log('Hey I am an example component!'); |