Code Monkey home page Code Monkey logo

storage-sevice-demo's Introduction

#Demo: Data Persistence in an Angular Service# This is a demo to show that services are persistent (data stored on them persists even when their use in the view is no longer being rendered) whereas controllers are not persistent (data stored on them disappears when they cease to be rendered).

How the Demo Works

The app has a controller with a counter ("controller counter ") and a service with a different counter ("service counter"). There is a third counter ("other counter") that is used to trigger when the view is and is not rendered (render the view with the counters when the "other counter" is less than 2. Then stop rendering the view when "other counter" is set to 2. Finally re-render the view when the "other counter" hits 3 and above.)

The "service counter" , "controller counter", and "other counter" each increment when you click buttons for each, but the view ceases to be rendered when "other counter" hits 2 When the view stops being rendered and then is brought back later (when "other counter" hits 3), the "service counter" stays where it originally was before the view was dropped whereas the "controller counter" starts back over at 0.

Setup

  1. Install packages: npm i

  2. Build using gulp: gulp

  3. Start the server: node server

  4. Navigate to localhost:5000 in your browser.

storage-sevice-demo's People

Contributors

craigaaroncampbell avatar

Watchers

James Cloos avatar

Forkers

cwshelly kbeame

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.