Making global in angular js
http://angularjs.org/
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.2/angular.js"></script>
<div ng-controller="MyController">
{{$scope.filteredData}}
</div>
JavaScript
var globVar = 1233;
var myApp = angular.module('myApp', []);
myApp.controller('MyController', function($scope, $filter) {
function MyCtrl($scope, $filter)
{
$scope.items = [
{id:1, name:'John',hobbies:[{kind:"spor"},{kind:"music"}]},
{id:2, name:'Steve',hobbies:[{kind:"opera"},{kind:"theatre"}]},
{id:3, name:'Joey'},
{id:4, name:'Mary'},
{id:5, name:'John',hobbies:[{kind:"swimming"},{kind:"opera"}]}];
$scope.filteredData = $filter('filter')($scope.items, {name:'John',hobbies:[{kind:'spor'}]});
$scope.json=JSON.stringify($scope.filteredData);
console.log($scope.json);
}
});