Git Product home page Git Product logo

learning-angular8's Introduction

Learning Angular 8

Just one of the things I'm learning. https://github.com/hchiam/learning

DesignCourse tutorial I'm following:

(Re)-run npm install -g @angular/cli to make sure the ng command is up to date.

Aside: You can run np help to get a list of available commands for the Angular CLI tool.

Start up commands

node -v
npm -v
npm install -g @angular/cli
ng help
ng new myapp
# routing? y
# SCSS
cd myapp
ng serve -o
# automatically opens and hot-reloads http://localhost:4200
# Control+C
ng build --prod

Folder structure

myapp
  e2e
  node_modules
  src
    app <-- you'll spend most of your time here on components and routing
    ..app.component.ts <-- main heart component
    assets
    environments
    ..index.html <-- here be the entry point <app-root>, but usually not doing work here
    ..styles.scss <-- global styles go here

app.component.ts

@Component({...}) is the component decorator, which is set up to connect to the component tag (e.g. <app-root>), the HTML file (e.g. app.component.html), and the CSS file (e.g. app.component.scss).

Routing

cd myapp
# ng generate component <component-name>, or just:
ng g c home
ng g c list

Keep <router-outlet></router-outlet> in HTML inside myapp/src/app/app.component.html.

Groups of files

ng g c <component-name> generates 4 files:

.ts      = brain
.html    = structure
.scss    = style
.spec.ts = test

Services

= special components that are reusable throughout your app

cd myapp
# ng generate service <service-name>
ng g s http

Aside CSS note

.container {
  display: flex; /* automatically fills up a row */;
  flex-wrap: wrap; /* to automatically create new rows */
  /* to wrap columns instead, change flex-direction and make sure height is bounded: */
  /* flex-direction: column; */
  /* height: 100vh; */
}

Build for production (dist folder)

cd myapp
ng build --prod

To run the production build on a local server, you can try:

cd myapp
# (stop any other running local server)
npm i -g lite-server
cd dist/myapp
lite-server

learning-angular8's People

Contributors

dependabot[bot] avatar hchiam 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.