Giter Site home page Giter Site logo

Comments (4)

Mark-McCracken avatar Mark-McCracken commented on May 13, 2024 1

Is this still valid syntax? Can't see that method available in my verison of @angularclass/hmr from npm. Can you suggest a working alternative for angular version 2.4?

from angular-hmr.

PatrickJS avatar PatrickJS commented on May 13, 2024

use @HmrState()

import {HmrState} from 'angular2-hmr';

/*
 * App Component
 * Top Level Component
 */
@Component({
    // The selector is what angular internally uses
    selector: 'wm-app', // <app></app>
    providers: [AppState],
    // The template for our app
    template: `
    <div>
       <h1>{{name}}</h1>
       <input [(ngModel)]="name" />
    </div>
    <br/>
    <div>
       <span>{{counter}}</span>
       <button (click)="incrementCounter()">Increment number</button>
    </div>
    `
})
export class AppComponent implements OnInit {
    name: string;
    @HmrState() counter: number;

    constructor(public appState: AppState) {
        this.name = 'Angular2 Minimal';
        this.counter = 0;
    }

    incrementCounter() {
        this.counter = this.counter + 1;
    }

    ngOnInit() {
        // Our API
        console.log('Initial App State', this.appState.state);
    }
}

from angular-hmr.

joaogarin avatar joaogarin commented on May 13, 2024

Tks! Works fine. I just had to do

this.appState.set('counter', this.counter);

when incrementing the counter.

Cool tks;)

from angular-hmr.

FernandoLeandroFernandes avatar FernandoLeandroFernandes commented on May 13, 2024

Try this for Angular 4:
npm install @angularclass/hmr --save

Source: https://github.com/gdi2290/angular-hmr

from angular-hmr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.