Skip to content

Instantly share code, notes, and snippets.

@rain1024
Last active August 29, 2015 14:05
Show Gist options
  • Save rain1024/3ae0d6a88ec51fe0f26c to your computer and use it in GitHub Desktop.
Save rain1024/3ae0d6a88ec51fe0f26c to your computer and use it in GitHub Desktop.
angularjs

image

AngularJS is an open-source web application framework, maintained by Google and community, that assists with creating single-page applications, one-page web applications that only require HTML, CSS, and JavaScript on the client side. Its goal is to augment web applications with model–view–controller (MVC) capability, in an effort to make both development and testing easier.

1, 2, 3

# create project
yo angular
# install dependecny
npm install
# run server
grunt serve
# browser website
browser 127.0.0.1:9000

Next Steps

Fell free to skip these steps. They are not big deals.

bower install font-awesome --save
bower install angular-bootstrap --save

Install

sudo npm install -g yeoman-generator
yo angular

Folder Structures

image

Routes, Forms, Services, Views

Plugin

Chart

https://github.com/cmaurer/angularjs-nvd3-directives

Workflow

Before starting AngularJS, make sure you've already had <mockup> and <api description>

Task Time
Make view 3 minutes
Make controller 5 minutes
Make service 5 minutes

Controllers

Generates a controller in app/scripts/controllers.

Example:

yo angular:controller user

Produces app/scripts/controllers/user.js:

angular.module('myMod').controller('UserCtrl', function ($scope) {
  // ...
});

References

Form Validation

Requires

  • Boostrap ~3.2.0

index.html

<!-- NAME -->
<div class="form-group"
  ng-class="{ 'has-error' : userForm.name.$invalid && !userForm.name.$pristine }">
  <label>Name</label>
  <input type="text" name="name" class="form-control" ng-model="user.name" required>
  <span class="glyphicon glyphicon-remove form-control-feedback"
    ng-show="newScanForm.url.$invalid && !newScanForm.url.$pristine"></span>
  <p ng-show="userForm.name.$invalid && !userForm.name.$pristine" class="help-block">
    You name is required.
  </p>
</div>

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment