JSFiddle

  • Angular Digest Loops Sample #1 is the latest revision

    Example showing before/after impact of digest loop.

    var digestCount = 0;
    (function (app) {
    
        function SyncService() {
            this.text1 = this.text2 = '';
        }
        SyncService.prototype.appendedText = function () {
            return this.text1 + this.text2 ...
  • Simple App #1 is the latest revision

    Very basic Angular app

    (function (app) {
        app.controller("myCtrl", function ($scope) {
            $scope.text = "Hello, world.";
        });
    })(angular.module("myApp",[]));
  • Alerts and Exceptions #1 is the latest revision

    Demonstration of capturing exceptions and alerting in Angular.

    (function (app) {
    
        function service() {}
    
        angular.extend(service.prototype, {
            alerts: [],
            alertId: 1,
            addAlert: function (msg) {
                this.alerts.push({
                    id: this.alertId ...
  • ControllerAs with Forms #2 is the latest revision

    Example of controller as with forms

    (function (app) {
        
        function ctrl() {
        }
        
        angular.extend(ctrl.prototype, {
            email: '',
            submit: function () {
                if (this.ctrlForm.email.$invalid) {
                    alert("Invalid email!");
                    return ...
  • 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 #6 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 #1 is the latest revision

    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 ...