Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Umbraco Festival 2013 - Introduction to AngularJS

Umbraco Festival 2013 - Introduction to AngularJS

Pete Bacon Darwin

November 08, 2013
Tweet

More Decks by Pete Bacon Darwin

Other Decks in Technology

Transcript

  1. Pete Bacon Darwin • Computer Programmer / Dad • .NET

    ◦ ex-IT Consultant (Avanade / IMGROUP) ◦ Some Umbraco 4(!) • AngularJS ◦ Google Team Member ◦ Book Author ◦ AngularUI Founder Member
  2. Sublime Scopes The glue between the Model and the View

    • Every HTML element has a Scope • Views access Scope properties and methods • Scopes provide data-binding between the View and the Model
  3. Cultured Controllers Initialize the scope with data and logic (Code

    Behind) <div ng-controller=”FriendController”> <ul> <li ng-repeat=”friend in friends”> {{ friend.name }} <button ng-click=” removeFriend(friend)”>X</button> </li> </ul> <input ng-model=”newFriend”> <button ng-click=” addFriend(newFriend)”>Add</button> </div>
  4. Constructive Controllers Controllers are just JavaScript functions appModule.controller(‘FriendController’, function($scope) {

    $scope.friends = [...]; $scope.addFriend = function(newFriend) {...}; $scope.removeFriend = function(friend) {...}; });
  5. Superb Services Services are Injectable Singleton Objects • $http: Make

    an AJAX request • $log: Log to the console • $timeout: Do something later • $location: Work with the browser address
  6. Tremendous Testability AngularJS Does Testing! • Separation of Concerns ◦

    Controllers and Services can be tested independently ◦ Views are declarative • Dependency Injection ◦ Dependencies can be mocked • Testing Tools
  7. Joyful Jasmine Behaviour Driven Development (BDD) ... ish describe ‘FriendController’,

    -> beforeEach -> ... it ‘should add 3 friends to scope’, -> expect($scope.friends.length).toBe 3 afterEach -> ...
  8. Powerful Protractor End to End Functional Testing for AngularJS https://github.com/angular/protractor

    • Protractor -> WebDriverJS -> Selenium • Simulate Interaction with your Web App
  9. Buy The Book Packed with real solutions to real problems!

    http://www.packtpub.com/angularjs-web-application-development/book