angular-app/angular-app

Name: angular-app

Owner: angular-app

Description: Reference application for AngularJS

Created: 2012-09-04 18:47:38.0

Updated: 2018-01-20 09:41:55.0

Pushed: 2017-05-18 04:21:00.0

Homepage: null

Size: 1925

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status

AngularJS CRUD application demo


Purpose

The idea is to demonstrate how to write a typical, non-trivial CRUD application using AngularJS. To showcase AngularJS in its most advantageous environment we've set out to write a simplified project management tool supporting teams using the SCRUM methodology. The sample application tries to show best practices when it comes to: folders structure, using modules, testing, communicating with a REST back-end, organizing navigation, addressing security concerns (authentication / authorization).

This sample application is featured in our book where you can find detailed description of the patterns and techniques used to write this code:

We've learned a lot while using and supporting AngularJS on the mailing list and would like to share our experience.

Stack
Build

It is a complete project with a build system focused on AngularJS apps and tightly integrated with other tools commonly used in the AngularJS community:

Installation
Platform & tools

You need to install Node.js and then the development tools. Node.js comes with a package manager called npm for installing NodeJS applications and libraries.

(Note that you may need to uninstall grunt 0.3 globally before installing grunt-cli)

Get the Code

Either clone this repository or fork it on GitHub and clone your fork:

clone https://github.com/angular-app/angular-app.git
ngular-app
App Server

Our backend application server is a NodeJS application that relies upon some 3rd Party npm packages. You need to install these:

Client App

Our client application is a straight HTML/Javascript application but our development process uses a Node.js build tool Grunt.js. Grunt relies upon some 3rd party libraries that we need to install as local dependencies using npm.

Building
Configure Server

The server stores its data in a MongoLab database.

Configure Client

The client specifies the name of the MongoDB to use in client/src/app/app.js. If your DB is not called “ascrum” then you need to change the MONGOLAB_CONFIG constant:

lar.module('app').constant('MONGOLAB_CONFIG', {
seUrl: '/databases/',
Name: 'ascrum'

Build the client app

The app made up of a number of javascript, css and html files that need to be merged into a final distribution for running. We use the Grunt build tool to do this.

It is important to build again if you have changed the client configuration as above.

Running
Start the Server
Browser Support

We only regularly test against Chrome 29 and occasionally against Firefox and Internet Explorer. The application should run on most modern browsers that are supported by the AngularJS framework. Obviously, if you chose to base your application on this one, then you should ensure you do your own testing against browsers that you need to support.

Development
Folders structure

At the top level, the repository is split into a client folder and a server folder. The client folder contains all the client-side AngularJS application. The server folder contains a very basic Express based webserver that delivers and supports the application. Within the client folder you have the following structure:

Default Build

The default grunt task will build (checks the javascript (lint), runs the unit tests (test:unit) and builds distributable files) and run all unit tests: grunt (or grunt.cmd on Windows). The tests are run by karma and need one or more browsers open to actually run the tests.

Continuous Building

The watch grunt task will monitor the source files and run the default build task every time a file changes: grunt watch.

Build without tests

If for some reason you don't want to run the test but just generate the files - not a good idea(!!) - you can simply run the build task: grunt build.

Building release code

You can build a release version of the app, with minified files. This task will also run the “end to end” (e2e) tests. The e2e tests require the server to be started and also one or more browsers open to run the tests. (You can use the same browsers as for the unit tests.)

Continuous testing

You can have grunt (karma) continuously watch for file changes and automatically run all the tests on every change, without rebuilding the distribution files. This can make the test run faster when you are doing test driven development and don't need to actually run the application itself.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.