Professional Documents
Culture Documents
AngularJS Cheat Sheet, by PUPA
AngularJS Cheat Sheet, by PUPA
Modules
Useful Features The process is more declarative which is easier to
understand
Directives
In unit-testing there is no need to load all modules,
ng-repeat instantiates a template once per item from a which may aid in writing unit-tests.
collection. It provides $index for index of the collection Additional modules can be loaded in scenario tests,
and $first, $middle, $last as Boolean. which can override some of the configuration and help
Template end-to-end test the application
<ul ng-controller='ListController'> Third party code can be packaged as reusable
<li ng-repeat='fruit in fruits'> modules.
{{fruit.name}} = {{fruit.amount}} The modules can be loaded in any/parallel order (due
</li> to delayed nature of module execution).
</ul> var myApp = angular.module('myApp', [])
myApp.controller('Ctrl', function ($scope){
Script $scope.target = 'world'
function ListController($scope){ });
$scope.fruits = [{name: 'mango', amount: 2},
{name: 'banana', amount: 5}, Template must specify name of target module.
{name: 'orange', amount: 4}]; <html ng-app="myApp">
} ...
</html>
ng-class dynamically set CSS classes on an HTML
element
<tr ng-repeat='fruit in fruits'
ng-class='{highlight: $first}'>
MEAN Stacks
MongoDB, Express, Angular, Node Unit Testing
Install & Run MongoDB With great power comes great responsibility.
>> mongod --dbpath=data/ Karma
Install karma globally so we can run unit-testing from
Install Node (npm is also installed)
command line.
Create project directory with package.json in it
>> npm install g karma
{
"name": "angularjs-seed",
"description": "A starter project for AngularJS", Create karma configuration files by running this command
"dependencies": { at project directories.
"express": "3.x" >> karma init
},
"devDependencies": { ... }
}