JSFiddle

  • Single Page App Example

    Simple single page app example.

    (function (app) {
        
        app.value('list', [{ id: 1, name: "Computer", price: 199.99 },
                           {id: 2, name: "Car", price: 39999.99 },
                           {id ...
  • Angular Integration Tests

    Performing integration tests with angular-mocks.

    (function (app) {
    
        app.factory("oDataSvc", ['$q', '$http', function ($q, $http) {
            return {
                checkEndPoint: function () {
                    var deferred = $q.defer();
                    $http.get("http ...
  • Berserker Style Maze #5 is the latest revision

    Algorithm to generate a maze based on the algorithm from the old Berserker game.

    (function (app) {
    
        var mazeGenerator = function () {
            var maze = [],
                pillarCoords = {
                    row: [4, 8, 16, 20],
                    col: [3, 6, 9, 12]
                },
                doors = [
                    [0 ...
  • Angular Rates App ES6 Harmony

    Eample of generating rates. ES6/Harmony version using Traceur compiler

    <script src="https://code.angularjs.org/1.3.9/angular.js"></script>
    <script src="https://google.github.io/traceur-compiler/bin/traceur.js"></script>
    <script src="https://google.github.io/traceur-compiler/src/bootstrap.js"></script>    
    <script type="module">
        var app = angular.module('rateApp', []);
    
        app.value('hours', [40, 45, 50]);
        
        app.value('times', [['Weekly',1], ['Monthly',4], ['Yearly (48 ...</script>
  • Angular Rates App #11 is the latest revision

    Eample of generating rates.

    (function (app) {
    
        'use strict';
    
        app.value('hours', [40, 45, 50]);
    
        app.value('times', [{
            time: 'Weekly',
            factor: 1
        }, {
            time: 'Monthly',
            factor ...
  • Reused promise #6 is the latest revision

    This shows that promises can be reused, so if you want to expose an API for deferred loading you simply keep track of a single deferred.

    (function (app) {
        
        function DelayedService($q) {
            var _this = this;
            this.defer = $q.defer();
            setTimeout(function () {
                _this.defer.resolve([1,2,3 ...
  • Qorlate - Promise correlation

    Use this library for disconnected promises to return a consistent API to the developers even when commands are returned asynchrnously or queuedl later.

    (function (qlate) {
    
        function getByValOrFn(ref) {
            return angular.isFunction(ref) ? ref() : ref;
        }
    
        function IdProvider() {}
    
        angular.extend(IdProvider.prototype, {
            id: 1,
            getId ...
  • Promises for Delayed Initialization

    Demonstrates a module that must initialize first and how to queue promises to initialize once but satisfy all requests.

    (function (app) {
        
        function DelayService($q) {
            var _this = this;
            this.$q = $q;
            this.loaded = false;
            this.resolutions = [];
            setTimeout(function () {
                _this.loaded ...
  • AJAX Query with jQuery

    Simple example of populating a list with jQuery AJAX.

    (function () {
        $.ajax({
            type: 'Get',
            url: 'http://services.odata.org/V4/OData/OData.svc/Products',
            success: function (result) {
                var idx = 0 ...
  • Don't Munge the DOM! #5 is the latest revision

    Examples of directives for DOM interaction

    (function (app) {
    
        function SizeService() {
            this.width = 0;
            this.height = 0;
        }
    
        app.directive('giveFocus', ['$timeout', function ($timeout) {
            return {
                restrict: 'A',
                replace ...