Go back to the main page

Using Yeoman along with the ng-book

 

 

Stop manually downloading and assembling Javascript, CSS, and HTML files. Use Yeoman for that plus get best practices baked right in.

  1. Install the latest versions of Nodejs, npm, and then yo (Yeoman)
  2. Create a directory for testing and switch into it.
  3.   $ mkdir ~/www/labs && cd $_
    
  4. Install the Yeoman generator for Angular: generator-angular
  5.   $ npm install -g generator-angular
    
  6. Bring forth Angular scaffolding with Yeoman.
  7.   $ yo angular
    
    Since we are just testing book examples don't install SASS or Bootstrap. Hit 'Enter' to select all the defaults in step 3.
  8. Take a look at what Yeoman installed by browsing through the generated directories.
  9. The app/ directory is the central directory.
  10. Run grunt serve.
  11.   $ grunt serve
    
    Grunt serve will open up this page at localhost port 9000.
  12. Copy the simple data binding example from page 12 to the clipboard.
  13. Get started by using this snippet.
  14. Then paste it into app/views/main.html
  15. You can put the snippet anywhere within app/views/main.html. For this example it is right above the HTML5 Boilerplate section.
  16. Save the file and the Yeoman grunt serve task will automatically reload the page.
  17. Notice after saving app/views/main.html that grunt watch immediately kicks off a browser reload. Nice!.
  18. Go back to the browser and we can see that the simple data binding example is working.
  19. Typing into the input box affirms that Angular is operative.
  20. Enjoy the book and Yeoman!

Comment on this article?