Category Archives: JavaScript

Minimal AngularJS with http get example

Your script file should have the following contents:

Then for your html file, which should include the script above and the Angular.js script, the contents should be:

Some important things to note:

  • The html tag contains an attribute with the name of your angular module SimpleAngularApp
  • The anonymous function is called immediately with a so called IIFE to setup the controller
  • The body tag has an attribute ng-controller that references the controller added to the module
Share

Immediately invoked function expression IIFE

Below is a code snippet for a Immediately invoked function expression IIFE. An IIFE is used to keep code out of the global namespace.

Share

Minimal AngularJS example

  • Include angularJS script
  • Place ng-app attribute on html tag
  • Define your controller in separate script file
  • Set ng-controller attribute on the appropriate tag

Share