0

我有这个非常烦人的问题。我需要能够从私有模块模式中访问公共模块功能。我已经对有问题的行发表了评论...有什么办法可以做到这一点吗?

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
    }

}]);
4

1 回答 1

0

阅读《学习 JavaScript 设计模式》一书后,我意识到你做不到。

于 2014-08-28T20:17:46.427 回答