AngularJS: Filter 2 Arrays | Angular Template
by Alberto Naperi Jr.
HTML
<div ng-controller="YourCtrl">
<div class="question">
1. <span ng-bind-html="trustedHtml"></span>
</div>
<h3>Fb Friends</h3>
<br />
<div ng-repeat="fbFriend in fbFriends">
{{fbFriend.name}}
</div>
<br />
<h3>Fb Friends present in App Friends</h3>
<br />
<div ng-repeat="appFriend in appFriends">
<div ng-repeat="fbFriend in fbFriends" ng-if="fbFriend.name != appFriend.name">
x{{fbFriend.name}}
</div>
</div>
</div>
JavaScript
'use strict';
var app = angular.module('myApp', []);
app.controller('YourCtrl', ['$scope', '$sce', function($scope, $sce) {
$scope.question = "Hi this is <br /> book";
$scope.trustedHtml = $sce.trustAsHtml($scope.question);
$scope.fbFriends = [
{"id": 1234, "name": 'bob'},
{"id": 4567, "name": 'john'},
{"id": 8910, "name": 'totoro'}
];
$scope.appFriends = [
{"id": 1, "name": 'bob', "fb_id": 1234},
{"id": 2, "name": 'john', "fb_id": 4567}
];
}]);