Saturday, March 8, 2014

Play with Angular: Get help from YEOMAN and Debugging with WebStorm


note: AngularJS is amazing.
warning: don't think in jQuery, think in AngularJS 

the developer is trying to "do jQuery" in the context of AngularJS. That's never going to work well. The view is the official record. Outside of a directive, you never, ever, never change the DOM. And directives are applied in the view, so intent is clear.

1. Let's start on the right foot: scaffolding workflow
2. Configure grunt server on WebStorm: so no need to start server from terminal app
3. Productive: 
Install AngularJS extension: more autocomplete to be productive
4. Debugging: 
Setup Debugger: so that we can be stress free (or minimum stress)
5. Process: Let generator do the job
6. Learning: Study & Get Help


1. Let's start on the right foot

Let Yeoman do the job. Yeoman will help us "scaffolding workflows for creating modern webapps, while at the same time mixing in many of the best practices that have evolved within the industry."

Install the required tools globally by running:

$ npm install -g yo

above command will installs grunt, karma etc
Karma: unit test framework specifically made for angular based application
Grunt: JavaScript task runner - automate various repetitive tasks such as js minification, reload server on change etc

$ npm install -g generator-webapp
$ npm install -g generator-angular 

I am going to call my application angular_play for this test project 
$ mkdir angular_play

open the directory you just created (angular_play in this case) from WebStorm

from WebStorm terminal interface, run the following to scaffold out a AngularJS project

$ yo angular  


install a dependency for your project from Bower
$ bower install angular-ui    

test your app     
$ grunt test

preview your app (formerly `grunt server`)              
$ grunt serve 


build the application for deployment             
$ grunt                            

Thank you YEOMAN!

2. Configure grunt server on WebStorm


"edit configuration"

"add new configuration" (command + N)
select Node.js and enter following parameters:


play "Grunt Server"


3. Install AngularJS extension 

WebStorm > Preferences > Install JetBeans plugins > Browse Repositories > "angluarjs" > double click search result and install

Ta-da! nice autocomplete and other support for all of the ng-goodness 




4. Setup Debugger

4.1. with WebStorm:
WebStorm > Edit Config > add "JavaScript Debug" > Specify file you want to debug > Click debug

Every time you reload page, it stops at breakpoint you specified!

4.2. with AngularJS Batarang Chrome Extension:

You can install AngularJS Batarang Chrome debugging extension for debugging and profiling. This performance tab comes in handy when you use function like $watch (listen for change)



4.3. Set "Pause on all exceptions" to halt when an exception occurs

Chrome > Dev Tools > Sources > toggle with icon looks like pig nose 

5. Let generator do the job

Why not use generator? 
from WebStorm terminal, just run command available 

6. Study & Get Help

egghead.io: web development training with AngularJS


Lastly....
feeling about AngularJS shown below (from Mr. Ben Nadel's blog) seems to be fairly common among devs. So let's not give up until you feel like "this is most awesome framework ever!"




3 comments:

  1. Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
    Angularjs developer

    ReplyDelete
  2. Kemudian permainan domino semakin tersebar luas sampai di pemerintahan putra Hui yakni Kao Tsung mulai pada tahun 1127 sampai dengan 1163 M.
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme terpercaya
    hobiqq
    paito warna oregon
    syair hk
    datahk

    ReplyDelete