WORKFLOWS MODERNOS CON ANGULARJS


ORIGAMI

Modelo


"The Model is the truth"
"The Model is the truth"
"The Model is the truth"
"The Model is the truth"
"The Model is the truth"
"The Model is the truth"
"The Model is the truth"

$scope y $rootScope


Los modelos SIEMPRE deben ser parte del scope.

Liga controladores con vistas

Jerarquias de scope

Un solo $rootScope por aplicacion (cuidado con el sobre uso)





$watch


Observa propiedades del scope


PERFORMANCE!!1111!1!!1!


  1. scope.$watch('name', function(newValue, oldValue) {  
  2. scope.counter = scope.counter + 1; 
  3. });


Propagacion de eventos



$emit ===> child a parent
function firstCtrl($scope){
    $scope.$on('someEvent', function(event, data) { console.log(data); });
}

function secondCtrl($scope){
    $scope.$emit('someEvent', [1,2,3]);
}
$broadcast ==> parent a child
function firstCtrl($scope){
    $scope.$broadcast('someEvent', [1,2,3]);
}

function secondCtrl($scope){
    $scope.$on('someEvent', function(event, mass) {console.log(mass)});
}

$on es la funcion que se encarga de manejar la respuesta




Controlador


Es una funcion que contiene la informacion del $scope, y agrega estado inicial y comportamiento al $scope.

  1. function GreetingCtrl($scope) {
  2. $scope.greeting = 'Hola!';
  3. }
  1. var myApp = angular.module('myApp',[])
  1. myApp.controller('GreetingCtrl', ['$scope', function($scope)
  2. $scope.greeting = 'Hola!';
  3. }]);



Caracteristicas de un controlador

No complejos

No DOM

Se usa para formularios

Modular

Responsabilidad especifica




HTTP://JSFIDDLE.NET/HYBRISCOLE/F4WAJ/

Filtros


Los filtros proveen formato al output de los templates

 {{ expresion | filtro | filtroN:param1:paramN }} 

Filtros built in



currency 
date 
filter
json 
limitTo
lowercase
number

Filtros Custom

Filtros

WORKFLOWS MODERNOS CON ANGULARJS

By Alberto Cole

WORKFLOWS MODERNOS CON ANGULARJS

  • 683