3. What is it?
Really big JavaScript file
JavaScript MVC framework (or MVW)
HTML syntax extensions
<html>
<script src=“angular.js“></script>
<script src=“app.js“></script>
<body ng-app=“myApp" ng-controller=“myController">
<h1>Sta se jede</h1>
<table>
<tr ng-repeat=“rest in restaurants">
<td>{{rest.name}}</td>
<td>{{rest.score}}</td>
</tr>
</table>
</body>
<html>
angular.module(‘myApp', []).
controller(‘myController‘, function($scope)
{
$scope.restaurants = [
{name:”Sparka”,score:”4/5” },
{name:”NijeSparka”,score:”3/5” }];
});
4. What is your app made of?
◦ Templates
◦ Expressions
◦ Controllers
◦ Model/Scope
◦ Modules
◦ Services
◦ Directives
◦ Filters
5. Templates
HTML extended with directives and expressions.
Angular “compiler” renderers DOM aka ”View” for Template.
ng-app minimum for angular to work. <html>
<script src=“angular.js“></script>
<script src=“app.js“></script>
<body ng-app=“myApp" ng-controller=“myController">
<h1>Sta se jede</h1>
<table>
<tr ng-repeat=“rest in restaurants">
<td>{{rest.name}}</td>
<td>{{rest.score}}</td>
</tr>
</table>
</body>
<html>
6. Controller and $scope
Controller is model/scope constructor
Model != $scope
$scope is an execution context for expressions
$scope functions:
◦ $watch
◦ $apply
7. Modules
Reusable container of app features.
Info about all other modules that this module depends on.
Angular injector is responsible for construction and lookup of dependencies.
9. Directives
HTML extensions in templates
Adding special behavior to custom elements attributes or classes
Built in:
◦ ng-app
◦ ng-controller
◦ ng-click
◦ ng-model
◦ ng-show
◦ …
11. Performance
Lots of watchers can lag the ui (more then 2000)
Every expression {{}}, every directive is new watcher
ng-repeat instances new template/scope for each item
bindonce in 1.3
15. Angular 2.0
Angular 2.0 next year
Angular 1.X will be supported for a year and half after 2.0 comes out.
RIP controllers/$scope, directives, modules.
controllers + template => web components.
directives => component, template, decorative components.
$scope => component.
modules => ES6 modules.
component, services: annotated ES 6 class.
Web components (Polymer).
ES6 (traceur).