Web #9


ang.png

$ Scope Commands

$rootScope – angularjs docs

$scope.$watch – angularjs docs

$scope.$broadcast – angularjs docs

$scope.$on – angularjs docs

this vs $scope – chevtek.io

ng-repeat

The ngRepeat directive instantiates a template once per item from a collection. Each template instance gets its own scope, where the given loop variable is set to the current collection item, and $index is set to the item index or key.

Special properties are exposed on the local scope of each template instance, including:

VariableTypeDetails
$indexnumberiterator offset of the repeated element (0..length-1)
$firstbooleantrue if the repeated element is first in the iterator.
$middlebooleantrue if the repeated element is between the first and last in the iterator.
$lastbooleantrue if the repeated element is last in the iterator.
$evenbooleantrue if the iterator position $index is even (otherwise false).
$oddbooleantrue if the iterator position $index is odd (otherwise false).

… full article

Filters

AngularJS provides filters to transform data:

  • currency Format a number to a currency format.
  • date Format a date to a specified format.
  • filter Select a subset of items from an array.
  • json Format an object to a JSON string.
  • limitTo Limits an array/string, into a specified number of elements/characters.
  • lowercase Format a string to lower case.
  • number Format a number to a string.
  • orderBy Orders an array by an expression.
  • uppercase Format a string to upper case.

… full article

More topics covered:

  • storing commands in Map
  • ng-model for <select … >
  • as keyword
  • parent + child scope
  • ng-repeat sortBy, filter

Links:

Leave a comment