AngularJS Service Dependencies

by Edward Tanguay

HTML

<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<div ng-app="app">
    <div ng-controller="CalculatorController">
       {{message}} 
    </div>
</div>

CSS

body {
    font-family:sans-serif;
    background-color: #f5f5f5;
}
div {
    margin:20px 5px;
}

JavaScript

function Calendar() {
	this.message = 'the calendar';    
}

// custom constructor
function Calendar_constructor(message, numberOfDays) {
    
}

angular.module('app', [])
.controller('CalculatorController', function($scope) {
    
    var calendar = new Calendar();
    $scope.message = calendar.message;
    console.log(calendar.constructor);
    console.log(calendar);
    
    //object does not have constructor, class has constructor
    console.log(calendar.hasOwnProperty('constructor'));
    console.log(Calendar.prototype.hasOwnProperty('constructor'));
    
    //notice these two are identify
    console.log(Calendar.prototype.constructor); // SAME
    console.log(calendar.constructor); // SAME
    
    //replace the constructor
    Calendar.prototype = { constructor : Calendar_constructor};
    var calendar2 = new Calendar('okok', 333);
    console.log(calendar2);
    
    
});