AngularJS : angular.js functions under the loop

AngularJS : angular.js functions under the loop

by Daan De Smedt

HTML

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<div ng-app="app" ng-controller="BasicController as vm" id="console-log"></div>

CSS

.console-line {
  font-family: monospace;
  margin: 2px;
  padding: 10px;
  border-bottom: 1px dotted #9E9E9E;
  background: #efefef;
}

JavaScript

/* CONSOLE.LOG DECORATOR */
console = {
  log: function(text) {
    $("#console-log").append($('<p class=\"console-line\"></p>').html(text));
  }
};

/* ANGULAR */
angular
  .module('app', [])
  .controller('BasicController', BasicController)

function BasicController($scope, $window) {
  /* declare VM */
  var vm = this;

  /*
   * angular.isArray
   * Determines if a reference is an Array. Alias of Array.isArray.
   */
  var _arr = ['creative', 'geeks', '.com'];
  console.log('angular.isArray for array var : ' + angular.isArray(_arr)); // true
  console.log('angular.isArray for Number 0 : ' + angular.isArray(0)); // false
  console.log('angular.isArray for String \'http://www.creative-geeks.com\': ' + angular.isArray('http://www.creative-geeks.com')); // false

  console.log('###############################################################');

  /*
   * angular.isDate
   * Determines if a value is a date.
   */
  var _date = new Date();
  console.log('angular.isDate for array var : ' + angular.isDate(_date));
  console.log('angular.isDate for Number 0 : ' + angular.isDate(0));
  console.log('angular.isDate for String \'http://www.creative-geeks.com\': ' + angular.isDate('http://www.creative-geeks.com'));

  console.log('###############################################################');

  /*
   * angular.isDefined
   * Determines if a reference is defined.
   */
  console.log('angular.isDefined for var : ' + angular.isDefined(0));
  console.log('angular.isDefined for undefined : ' + angular.isDefined(undefined));

  console.log('###############################################################');

  /*
   * angular.isUndefined
   * Determines if a reference is defined.
   */
  console.log('angular.isUndefined for var : ' + angular.isUndefined(0));
  console.log('angular.isUndefined for undefined : ' + angular.isUndefined(undefined));

  console.log('###############################################################');

  /*
   * angular.isElement
   * Determines if a...