[英]How can I access the public methods on a module from a private?
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
}
}]);
看完《 学习JavaScript设计模式》这本书后,我意识到您做不到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.