Angular function constructor in Controller
- by BigHeadCreations
In normal JS I can do this:
function Droppable() {
this.relevant = true;
this.uuid = generateUUID();
};
var generateUUID = function() {
return '12345';
}
console.log(new Droppable); // returns Droppable {relevant: true, uuid: "12345"}
But in Angular I have this:
angular.module('myApp').controller('MyCtrl', ['$scope', function($scope) {
function Droppable() {
this.relevant = true;
this.uuid = generateUUID();
}
var generateUUID = function() {
return '12345';
}
// initalize droppable areas
$scope.region1 = [new Droppable];
$scope.region2 = [new Droppable];
$scope.region3 = [new Droppable];
}]);
I am trying to make 3 droppable areas all with a UUID.
But when I do this I get 'undefined is not a function' referring to the line this.uuid = generateUUID(); in function Droppable() {...}
Why is that?