I got stuck , can any one please help me. Here are codes. I am writing grabData service to get data from url. Then in the controller firstcontroller I am filtering data according to search box: This is the code:
.factory("grabData",['$http',function($http){
return{
showData:function(){
return $http.get("/http://localhost:5555/sampleData.json");
}
}
}])
.controller('firstController',function($scope, $filter,grabData) {
grabData.showData().success(function(data){
$scope.items = data;
$scope.items1 = $scope.items;
$scope.$watch('search', function(val){
$scope.items = $filter('filter')($scope.items1, val);
});
}
And HTML code is: <div ng-controller="firstController">
<input type="text" ng-model="search">
</div>
Can any one please help me in displaying $scope.items in next controllers:
.controller('secondcontroller',function($scope){
// Here I want to use $scope.items , from first controller
})
.controller('thirdcontroller',function($scope){
// Here I want to use $scope.items , from first controller
})
.controller('fourthcontroller',function($scope){
// Here I want to use $scope.items , from first controller
})
Can any one please help to solve this problem.