Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //In my code i don't implement item 6, instead i use a ternary function to change the loadState value.
- //dashboard.component.ts
- import { Component } from '@angular/core';
- @Component({
- selector: 'app-dashboard',
- template: `
- <button (click)="onChangeState()">Change Load State</button>
- <p>Current state: {{ loadState }}</p>
- `
- })
- export class DashboardComponent {
- loadState = 'loading';
- onChangeState() {
- this.loadState === 'loading' ? this.loadState = 'finished' : this.loadState = 'loading';
- }
- }
- //app.module.ts
- import { FormsModule } from '@angular/forms';
- ...
- import { DashboardComponent } from './dashboard.component';
- @NgModule({
- declarations: [
- ...
- DashboardComponent
- ],
- imports: [
- ...
- FormsModule
- ],
- providers: [],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
- //app.component.ts
- ...
- <app-dashboard></app-dashboard>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement