Exercise 28: Creating Modules and Controllers - jkneal/spring-angular-train GitHub Wiki
Goals
Learn how to create modules and controllers
Instructions
- In
angular/scripts, create a file named 'app.js' - In app.js, create an Angular module with name ‘storeApp’ (the module should have no dependencies). Load the ‘storeApp’ module inside app.html
- Create a new directory named ‘controllers’ in
angular/scripts - Create a file named store-controller.js in
angular/scripts/controllers - In store-controller.js, create a controller named ‘storeCrtl’. Associate the controller with the body element in app.html
- Within the controller function you created in step 5, log the following statement to console: ‘store controller has been loaded’
- Include the two new script files in app.html
VERIFICATION
- Start the training application and go to the app home page
- Click on the link 'Angular Exercises'
- 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