JSFiddle - React, Tailwind, and code Playground
by Alexander Branchugov
HTML
<script src="https://code.angularjs.org/1.6.6/angular.js"></script>
<div ng-app="myApp">
<div ng-controller="MyCtrl">
<span ng-bind="arr1"></span><br />
<span ng-bind="arr"></span>
</div>
</div>
JavaScript
var myApp = angular.module('myApp', []);
var MyCtrl = myApp.controller('MyCtrl', ['$scope', function MyCtrl($s) {
var arr1 = [1,2,3,4,5,6,7,8],
arr2 = [1,5,8,9];
//$scope.arr1 = [];
$s.arr = [];
$s.arr1 = arr1.filter( item => {
if ( arr2.indexOf( item ) != -1 ) {
return true;
}
$s.arr.push( item );
return false;
} );
}] );