Quick intro to Angular.js

Agenda

  • Directives, filters, and services
  • Controllers, scopes and data binding
  • Dependency injection

Directives

Filters

  • Format data to the way it should be displayed to the user

  • Can be used in templates, services, directives, and controllers

  • Angular comes with a bunch of built-in filters too, including currency, date, and limitTo

  • Example: http://jsfiddle.net/sjmcpherso/5WnTA/

Services

  • This is where the actual business logic is
  • Services can be created with any a number of methods such as .factory, .service, and .provider
  • Services can be injected to other services, directives, and filters
  • Angular comes with a lot of built-in services like $http, $location, and $interval

Controllers

  • Gets a scope injected dynamically
  • Works with models and updates the scope, based on user interactions from the view
  • Example: http://jsfiddle.net/U3pVM/8364/

Scopes

  • Scopes are objects that hold the models for an application
  • They allow to execute expressions in a context
  • Scopes are arranged in hierarchical structure that mimics the DOM structure
  • Each scope inherits from a parent scope with all scopes inheriting from $rootScope

Data binding

  • Angular keeps models updated by listening to DOM events and updating models accordingly
  • Views display updated models by being notified every time a model changes
  • Example: http://jsfiddle.net/hmyZB/

Dependency injection

The End

Questions?

Quick intro to Angular.js

By Ronen Amiel

Quick intro to Angular.js

  • 520