Giter Site home page Giter Site logo

khaledelansari / angular1.5-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from duluca/angular1.5-starter

0.0 2.0 0.0 1.55 MB

A batteries-included Mobile-First Angular 1.5+ and Angular Material Seed Project

Home Page: http://thejavascriptpromise.com

License: MIT License

HTML 30.94% JavaScript 56.11% CSS 12.96%

angular1.5-starter's Introduction

Angular 1.5+ and Angular Material Starter Project

A batteries-included Mobile-First Angular 1.5+ and Angular Material Seed

TL;DR: Scroll to the bottom for commands you need to run

Angular Starter demonstrates several important concepts in building a scalable code architecture for Angular 1.5.x. Following the patterns demonstrated in this project will help write clean, maintainable code that is more inline with Angular 2.0 style coding.

Launch demo here.

Pull the Docker Image docker pull duluca/angular1.5-starter

Login

Notice: While, this is my recommend Angular 1.x code architecture for production use, please not that this technique is not supported beyond Angular 1.5.11 due to changes in Angular 1.6, which lacks Angular Material 1.1.3 support and [email protected]. Read further below for more details.

Why Use This Starter?

This project leverages components and the component router technology, similar to the way they're utilized in Angular 2. Using ngComponentRouter, Angular Material 1.1.3 and Angular 1.5.11, you can build great production quality applications. The component architecture allows you to follow clean code and SOLID principals, where you can build multi-hundred view apps without your code architecture collapsing under its own weight.

Meanwhile you'll be introduced to concepts that form the basis of Angular 2, while leveraging your Angular 1.x skills. If you're looking for a 3-5+ year solution, I highly recommend you start with Angular 2, as that is the foundational framework that'll be supported for Angular v.Next beyond Angular 2.

For a complete example of how to leverage majority of the features of the router, see https://github.com/duluca/angular1.5-starter. Fork it, create issues with it, otherwise just clone it and use it.

Concepts Covered

Scalable Angular Architecure

  • Learn how to write Angular components, ditch $scope forever
  • Create reusable and nested components - see how the Dashboard component is a child of Admin the admin component. This is true from a routing perspective, folder organization perspective and dependency management perspective. Seperating all of these 3 concerns is critical in allowing multiple teams or team members to work on the same app without impacting each other or creating nasty merge conflicts.
  • Define child root routes that can define their own route structure
  • Use Promise-based service calls

Great Looking Mobile-First Design & Form Validation with Angular Material

Navigation

  • Learn how you can incorporate Angular Material with a responsive design in to your app
  • SideNav with a hamburger menu and a top NavBar provide a complimentary navigation experience
  • Properly validate Angular forms, leveraging ng-messages
  • Access rich and easy to use Material Desing Icons (mdi) icon library
  • Included Angular Material Data Table library for paginated datagrids (see source repo for sample usage)
  • Ui service that convienently wraps Material function for toast notifications and simple alerts to call from your code.

Authentication Hooks and Role Based Navigation

Form Validation

- Sample Authentication and Account services demonstrate how to do role based security - Enfore security and roles in navigation using ngComponentRouter lifecycle hooks - Utilize pre-built Material design login component with iOS style shake animation on error - Bring your own auth library and hook it in to `Auth` service provided - Use pre-built caching service that leverages $cookies

Packaging and Publishing Best Practices

  • Use npm as your only dependency repository with Browserify
  • npm-shrinkwrap locks down your dependencies to avoid issues with other developers or deployments to servers
  • Use Gulp.js to streamline build tasks
  • Pre-built Gulp tasks to minify, combine JS, HTML and publish other static assets
  • Enforce clean-room development environment to avoid mistakes and accidental exposure of assets, because public folder is created from scratch every time
  • Use JsHint for enforcing coding style standards (linting)

Unit Testing

  • This is notably missing from this starter. It is a topic that too often gets left out. I recommend using Jasmine to test particular JavaScript functions, which you can isolate to their own files using module.exports and write simple unit tests.
  • Selenium tests are a great way to smoke test the major functions of your app. Getting too granular than that is a loosing battle.
  • Your mileage may vary with Protractor.
  • I highly recommend that all your important business logic to reside server-side and unit tested there.

Find Your Way Around the Code

  • I recommend using Visual Studio Code as your code editor.
  • All dependencies come from npm. As a result, your first stop should be package.json. Understand what each package does.
  • All of your static assets should go under the static folder. index.html should rarely ever be updated. All js and html files are combined to a single file. A notable exception is css because you may want to change those links to CDN targets and I find it unreliable to compile, combine or minify 3rd party css resources.
  • All Angular Code goes under the app folder. App is bootstrapped in app/component/app/app.js.
  • Public folder is the only folder you should serve to the public internet. It is built from scratch everytime, so doesn't make any changes in there. Ignore the scratch folder completely.

How to Run the Project

There are two ways to run the project, one by building the source code yourself, the other by running the Docker image.

Run via Building Source Code

  • From the root application directory run the following:
  • npm install gulp-cli -g
  • npm install http-server -g (This is required to serve the project from your local folder)
  • npm install
  • npm start

Run via Docker

For further details on how the Docker image is put together, refer to https://github.com/duluca/minimal-node-web-server.

Dev Norms

See dev-norms.md for a set of sensible default norms for your team to follow. Modify and update as a living repository of your norms.

Did You Know You Don't Need Gulp?

You can leverage npm as your task runner. Here's a sample gist to get you started!

angular1.5-starter's People

Contributors

duluca avatar kentonbmax 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.