Skip to content

Instantly share code, notes, and snippets.

@santisbon
Last active March 16, 2023 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save santisbon/dafd0a7729707f6eff09e664068e1201 to your computer and use it in GitHub Desktop.
Save santisbon/dafd0a7729707f6eff09e664068e1201 to your computer and use it in GitHub Desktop.
Commonly used commands when developing with the angular-fullstack Yeoman generator. #angular

Cheat sheet

Update npm and install the necessary packages

$ sudo npm install -g npm
$ sudo npm install -g yo grunt-cli gulp-cli bower generator-angular-fullstack

Create a folder for your project and cd into it

$ mkdir my-new-project && cd $_
$ yo angular-fullstack [app-name]

Build the solution with Grunt or Gulp

$ grunt build

Run server and client tests (grunt/gulp)

$ grunt test

Run server, client, or end-to-end tests (grunt/gulp)

$ grunt test:server
$ grunt test:client
$ grunt test:e2e

Run the application in dev mode (grunt/gulp)

$ grunt serve

Run the application in production mode (grunt/gulp)

$ grunt serve:dist

Client: Create a Products page

Create the route. This will create the route, controller, template, CSS, and test file.

$ yo angular-fullstack:route products

Create a products factory or service (the model). A service returns a constructor function (the "this" keyword is available) so we need the "new" operator. A factory gets the value returned by invoking the function. It allows creating a closure where the returned object exposes "public" methods.

$ yo angular-fullstack:factory products

Steps to do in the code:

  1. Edit the product factory/service to return the products data.
  2. By convention the name of services/factories are capitalized so update it from products to Product.
  3. Inject the product factory into the product controller and make it available to the view through $scope.
  4. Edit the HTML template to use the products exposed through $scope.

Server: Create a Products API

$ yo angular-fullstack:endpoint product
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment