Personal notes & cheatsheet on JS.
- tests mocha (never tried jasmine)
- promises Q.js or bluebird.js. P.S.: just use ES6 Promise
- prefer lodash.js over underscore.js
- good web (micro) frameworks express.js, koa.js
- nodemon
- good editor brackets.io (with markdown plugin)
- good MVVM/MVC frameworks knockout.js and of course Angular.js
- auto-format code: find test -type f | xargs js-beautify -r -s 2
- streaming handbook
- test with Karma runner and/or Protractor
- grunt for minify and such
- npm install -g grunt-cli
- bower for pulling deps:
- npm install bower # or -g?
- touch bower.json
- bower install
- what's best for pulling deps from browser? TODO
- what about Bootstrap? Mostly for CSS? TODO
- {{controller.something['bla']}} is not 100% equivalent to ng-model="controller.something['bla']": the latter does two-way binding
- ajax examples:
$scope.saveStatus = "saving...";
$http.put('/admin/configBuilder', $scope.config_builder).success(function () {
$scope.saveStatus = "save complete";
})
.error(function (err) {
$scope.saveStatus = "save failed:" + err }); This alrdy takes care of $ $hashKey removal, very convenient. How can this easiest be done promise-based? TODO - good looking autocomplete: http://ngmodules.org/modules/ngAutocomplete, but note this is GoogleMaps-specific. Others are at http://ngmodules.org/tags/autocomplete. This web site doesn't get much use (yet?). P.S. http://angular-ui.github.io/bootstrap/ has autocomplete aka Typeahead, that's probably the best one atm.
- on parent scopes see here "your child controller will inherit all scope variables. So theoritically you don't have to call $parent"
- note Python-like list/generator comprehension in Angular views, e.g. typeahead="state for state in getStates($viewValue) | filter:$viewValue | limitTo:8"/> Neat!