在角JS 2 $范围数组的区别 [英] Difference of two $scope array in angular js
本文介绍了在角JS 2 $范围数组的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法返回在angularjs
Is there a way to return the difference between two array present in a scope in angularjs
例如,
$scope.user1 = ['a', 'b'];
$scope.user2 = ['a', 'b', 'c', 'd'];
这两个差异应该给我的另一个作为
$ scope.user3 = ['C','D']
Difference of these two should give me an another as $scope.user3= ['c','d']
推荐答案
Underscore.js有差异的方法这一点。
Underscore.js has the difference method for this.
http://underscorejs.org/#difference
$scope.user1 = ['a', 'b'];
$scope.user2 = ['a', 'b', 'c', 'd'];
$scope.user3 = _.difference($scope.user2, $scope.user1);
这篇关于在角JS 2 $范围数组的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文