我正在使用 angularJS,我遇到了一个问题: 我有 2 个 $scope:
$scope.list1{
Object 1,
Object 2,
Object 3}
$scope.list2{
Object 4,
Object 5,
}
我想要这个结果:
$scope.res{
Object 1,
Object 2,
Object 3,
Object 4,
Object 5}
agularJS不知道用什么函数,我用过
angular.merge($scope.res, $scope.list1, $scope.list2)
但我得到的结果是空的 我不知道 merge 是不是好的功能所以我需要你的帮助
最佳答案
Angular 方式 将使用 angular.extend
:
Extends the destination object
dst
by copying own enumerable properties from thesrc
object(s) todst
. You can specify multiple src objects. If you want to preserve original objects, you can do so by passing an empty object as the target:var object = angular.extend({}, object1, object2)
.
angular.extend($scope.list1, $scope.list2);
关于javascript - AngularJS 将两个列表合二为一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43763668/