Comments (6)
I'm using the following code myself:
$interval(function () {
if (_this.scope.session_settings.auto_refresh) {
_this.scope.indexVM.refresh();
}
}, 1000 * 10);
Hope this helps!
On Mon, Nov 23, 2015 at 6:29 PM, Jordan Moore [email protected]
wrote:
I am not too familiar with Angular, but I am looking for a way to
periodically refresh the indexVM variable so the search results will
refresh every few seconds.I have hooked a custom controller to the view with this code and I can see
in the console that the $scope.getData() function gets called every 5
seconds. I would like to somehow call the refresh method on the
IndexController here which I can see in the source is inside the
IndexDirective. I've tried using $scope.indexVM and injecting the
$controller service, but no success to get what I was looking for.
Controllerangular.module('demo.search', ['ngRoute', 'elasticui'])
.config(['$routeProvider', function($routeProvider) { $routeProvider.when('/search', { templateUrl: 'search/search.html', controller: 'SearchCtrl' }); }]) .controller('SearchCtrl', ['$scope', '$timeout', function($scope, $timeout) { // Function to get the data $scope.getData = function(){ console.log("Fetched data!"); }; // Function to replicate setInterval using $timeout service. $scope.intervalFunction = function(){ $timeout(function() { $scope.getData(); $scope.intervalFunction(); }, 5000); }; // Kick off the interval $scope.intervalFunction(); }])
HTML
I am using the SearchBoxDirective and the search results populate
appropriately when I type in the input field.SearchResults
{{doc._source.doc.text}}
—
Reply to this email directly or view it on GitHub
#64.
from elasticui.
Looks promising, but where exactly do I place that?
I tried putting just that if
statement inside my $scope.getData
then placing that entire block directly into my SearchCtrl
and both times I got ReferenceError: _this is not defined
.
from elasticui.
I think you should just be able to call $scope.indexVM.refresh() im your
getData function. Does that work or is indexVM not defined?
On Nov 23, 2015 6:51 PM, "Jordan Moore" [email protected] wrote:
Looks promising, but where exactly do I place that?
I tried putting just that if statement inside my $scope.getData then
placing that entire block directly into my SearchCtrl and both times I
got ReferenceError: _this is not defined.—
Reply to this email directly or view it on GitHub
#64 (comment).
from elasticui.
Correct, $scope.indexVM
is undefined.
from elasticui.
Hi Jordan,
I think this has to do with the Angular Scope chain.
In my app for example, I set up the main controller as follows:
then, I do have access to indexVM on the MainController scope.
I hope this helps + you can find a good way to access the indexVM object on your scope
from elasticui.
Okay cool! That seems to work. For future reference, since your HTML seems to be hidden in GitHub, here it is again:
<body ng-app="stats" ng-controller="MainController" eui-index="'indexname'">
I do have an ng-view
within my body
tag, though, and my Controller is hooked to that (the ng-view
is what I posted before). I ended up moving the eui-index
directive from the view into the body
tag of my index.html
.
Thanks!
from elasticui.
Related Issues (20)
- multiple items cannot be selected using eui-checklist widget
- Input search does not refresh the search when the clean icon is clicked
- Partial search HOT 1
- Impossible to use more than one searchbox HOT 1
- Top level filter parameter deprecated in ES 5
- checkbox does not filter
- Hello!
- is it possible to use ElasticUI with elasticsearch 5.x? HOT 6
- Has "ElasticUI" been tested with partial files?
- change indexVM.page in controlle HOT 1
- How do I add some logic to eui-query? HOT 1
- Default to AND operator in searchbox HOT 1
- Term Aggregation - Custom order
- Sort HOT 1
- Is it possible to add custom parameter to a url?
- Multilanguage, translate ... change the {{bucket.key}} on the fly
- Access Control with POST/GET/DELETE/...
- Space issue in Single Select and Checkbox HOT 2
- UseCase Searchbox to filter only one facet
- jsfiddle Demo does not work.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticui.