如何通过引用而不是按值将$ scope中的Angular数组传递给函数?

时间:2017-05-10 14:26:31

标签: angularjs

在我的表单中,我将范围内的模型传递给这样的行为:

                   <a href="#"
                       ng-click="removeAnEditSelectionFromModelCollection(data.editAction.actionType1.actionsRecommendedByLer, actionRecommendedByLer.lookUpDetailId, 'editActionRecommendedByLerSelect')"
                       class="functionalLinks text-danger">
                        <i class="glyphicon glyphicon-trash"></i>
                        DELETE
                    </a>

该模型是一个Angular数组: $ scope.data.editAction.actionType1.actionsRecommendedByLer

接收功能如下所示:

$scope.removeAnEditSelectionFromModelCollection = function (modelCollection, lookUpDetailId, selectId) {
            console.log("In removeAnEditSelectionFromModelCollection");
            modelCollection
                = $.grep(modelCollection,
                    function (n, i) {
                        console.log("n.lookUpDetailId: " + n.lookUpDetailId + ", lookUpDetailId: " + lookUpDetailId);
                        return (n.lookUpDetailId !== lookUpDetailId);
                    }
                 )
            console.log("modelCollection.length: " + modelCollection.length);

            var element = $('#' + selectId + ' option[value = "' + lookUpDetailId + '"]');
            // console.log(element.text());
            element.removeAttr('disabled');
            element.css('background-color', '');
        }

好像它是通过值传递的。我可以通过某种方式通过引用传递这个,所以在grep我的表与Angular数组的ng-repeat将反映更新?

0 个答案:

没有答案