AndrewJBateman / angular-components-study

:clipboard: App to study differences between dumb (presentational and portable) components and smart components (that can have logic, trigger change detection and manage data/services).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

⚑ Angular Tutorial App

  • App to study differences between dumb (presentational and portable) components and smart components (that can have logic, trigger change detection and manage data/services).
  • Tutorial code from Digital Fluency but with updates due to updated Angular versions - 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 uses the following Angular concepts: components, data & property binding etc.

πŸ“· 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

  • view-repos component that gets API repo data from github
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http'
import { map } from 'rxjs/operators';

@Component({
  selector: 'app-view-repos',
  templateUrl: './view-repos.component.html',
  styleUrls: ['./view-repos.component.css']
})

//smart component - loads API data from the internet,
//the data from this ViewReposComponent is consumed by the 'app-repo-list'
//in the app-repository-view component.
export class ViewReposComponent implements OnInit {
  list: Observable<any[]>

  constructor(http: HttpClient) {
    const path = 'https://api.github.com/search/repositories?q=angular';
    this.list = http.get<{items: any[]}>(path)
      .pipe(
        map(data => data.items),
      );
  }

  ngOnInit() {
  }
}

πŸ†’ Features

  • Demonstrates difference between smart and dumb components by whether they can trigger change detection/manage data & services

πŸ“‹ Status & To-Do List

  • Status: Working.
  • To-Do: nothing

πŸ‘ Inspiration

πŸ“ License

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

βœ‰οΈ Contact

About

:clipboard: App to study differences between dumb (presentational and portable) components and smart components (that can have logic, trigger change detection and manage data/services).

License:MIT License


Languages

Language:TypeScript 76.0%Language:JavaScript 16.4%Language:HTML 6.9%Language:CSS 0.8%