I have this really annoying problem. I need to able to access the public module function from within a private module pattern. I have written a comment on the problematic line...is there any way to do this?
angular.module("myApp").factory('models', [function () {
function itemModel(dtoItem) {
this.type = dtoItem.type;
}
function groupModel(dto) {
this.items = [];
angular.forEach(dto.getFeatures(), function (item) {
self.items.push(new itemModel(item)); //THIS NEEDS TO BE self.items.push(new ItemModel(item)); (Notice the use of the capital letter to denote a public function) so that I can run a test externally and check the type of the 'items'
});
}
return {
ItemModel: itemModel,
GroupModel: groupModel
}
}]);
After reading the book Learning JavaScript Design Patterns I have realised you can't.