如何通过深度克隆问题解决角度ng-options跟踪?

问题描述 投票:1回答:1

ng-options="branch as branch.name for branch in ordersItemClientInfo.branches track by branch.id"

在我的例子中,“branches”是一个对象数组,每个对象都有字段引用到如此深的对象(map geoObject)。 Angular尝试复制该对象并失败!

来自angular.js:

getViewValueFromOption: function(option) {
  // If the viewValue could be an object that may be mutated by the application,
  // we need to make a copy and not return the reference to the value on the option.
  return trackBy ? angular.copy(option.viewValue) : option.viewValue;
}

我不需要副本,我需要选择原始对象。我该怎么做?

angularjs ng-options angularjs-track-by
1个回答
0
投票

也许你可以尝试做一个JSON.stringify(显示它之前的每个项目),然后在你想要显示时在模板中制作JSON.parse

© www.soinside.com 2019 - 2024. All rights reserved.