Exercise 28: Creating Modules and Controllers - jkneal/spring-angular-train GitHub Wiki

Goals

Learn how to create modules and controllers

Instructions

  1. In angular/scripts, create a file named 'app.js'
  2. In app.js, create an Angular module with name ‘storeApp’ (the module should have no dependencies). Load the ‘storeApp’ module inside app.html
  3. Create a new directory named ‘controllers’ in angular/scripts
  4. Create a file named store-controller.js in angular/scripts/controllers
  5. In store-controller.js, create a controller named ‘storeCrtl’. Associate the controller with the body element in app.html
  6. Within the controller function you created in step 5, log the following statement to console: ‘store controller has been loaded’
  7. Include the two new script files in app.html

VERIFICATION

  1. Start the training application and go to the app home page
  2. Click on the link 'Angular Exercises'
  3. Open the browser console (in Chrome Ctrl + Shift + J, or right click -> Inspect Element then select the console tab), and verify the message ‘store controller has been loaded’ appears