Code Monkey home page Code Monkey logo

angular-tour-of-heroes's Introduction

⚑ Angular Tour of Heroes

  • This is a data-driven app that stores and displays a list of heroes, edits their details and allows navigation of the data using different views.
  • Tutorial code from Angular - see πŸ‘ Inspiration below.
  • Note: to open web links in a new window use: ctrl+click on link

GitHub repo size GitHub pull requests GitHub Repo stars GitHub last commit

πŸ“„ Table of contents

πŸ“š General info

  • This app does the following:
  1. Uses built-in Angular directives to show and hide elements and display lists of hero data.
  2. Creates Angular components to display hero details and show an array of heroes.
  3. Uses one-way data binding for read-only data.
  4. Adds editable fields to update a model with two-way data binding.
  5. Binds component methods to user events, like keystrokes and clicks.
  6. Enables users to select a hero from a master list and edit that hero in the details view.
  7. Formats data with pipes.
  8. Creates a shared service to assemble the heroes.
  9. Uses routing to navigate among different views and their components.

πŸ“· Screenshots

Example screenshot.

πŸ“Ά Technologies

πŸ’Ύ Setup

  • Run ng serve for a dev server.
  • Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

πŸ’» Code Examples - from Angular Tour of Heroes code

  • in-memory-data-service file
// Angular in-memory web api module
// This provides the InMemoryDataService as a parameter for the .forRoot method of the InMemoryServiceiModule module.
// Overrides the createDb() method.

import { InMemoryDbService } from 'angular-in-memory-web-api';
import { Hero } from './hero';
import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root',
})
export class InMemoryDataService implements InMemoryDbService {
  createDb() {
    const heroes = [
      { id: 11, name: 'Mr. Nice' },
      { id: 12, name: 'Narco' },
      { id: 13, name: 'Bombasto' },
      { id: 14, name: 'Celeritas' },
      { id: 15, name: 'Magneta' },
      { id: 16, name: 'RubberMan' },
      { id: 17, name: 'Dynama' },
      { id: 18, name: 'Dr IQ' },
      { id: 19, name: 'Magma' },
      { id: 20, name: 'Tornado' }
    ];
    return {heroes};
  }

  // Overrides the genId method to ensure that a hero always has an id.
  // If the heroes array is empty,
  // the method below returns the initial number (11).
  // if the heroes array is not empty, the method below returns the highest
  // hero id + 1.
  genId(heroes: Hero[]): number {
    return heroes.length > 0 ? Math.max(...heroes.map(hero => hero.id)) + 1 : 11;
  }

  constructor() { }
}

πŸ†’ Features

  • CRUD operations: heroes can be created, read, updated (name only) and deleted from a 'My Heroes' list.
  • Clicking on a hero routes to a hero details page.
  • A 'Messages' list records fetching and deleting of heroes from the My Heroes list.

πŸ“‹ Status & To-Do List

  • Status: Working app with in-memory database storage of heroes.
  • To-Do: add theme colors and functionality.

πŸ‘ Inspiration

πŸ“ License

  • This project is licensed under the terms of the MIT license.

βœ‰οΈ Contact

angular-tour-of-heroes's People

Contributors

andrewjbateman avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.