ma-point-query is not updating
-
I have an issue where I believe the query attribute in ma-point-query is pulling data from my controller before it has a chance to initialize. Here is the HTML
<span>{{$ctrl.devName}}</span><br><span>{{devPoints[1].deviceName}}</span> <ma-point-query id="d61e8607-03c8-48ad-965a-96a1d76130e9" query="{deviceName:$ctrl.devName}" promise="promise" points="devPoints"></ma-point-query>
The Spans are included for testing purposes.
In my controller, I'm binding to a data point and then trying to pull it's deviceName back and use it in the query filter. Thus creating a filtered list of points for that device. Right now the query seems to be binding before the controller is updating the deviceName. So my point list actually contains multiple devices. All other bindings to 'devName' seems to be fine. Both of these spans should say the same thing.
I've tried many ways including binding to other locations. It just seems that the query isn't updating once the binding completes. Any ideas? Or am I missing something?
-
@sstuhlmann check your Chrome dev tools betwork tab to see what REST API requests for data points are actually issued.
If it is like you say you can stop the query running until you retrieve your device name by using a
ng-if
e.g.<ma-point-query ng-if="$ctrl.devName">
Alternatively do something like this, so that if devName is undefined it queries for the deviceName being null instead (which should return 0 results)
<ma-point-query query="{deviceName:$ctrl.devName || null}">
Although what I suspect is actually happening is that the query is not exact, I think that type of query is actually a fuzzy query, it will search for
deviceName LIKE %devName%
in the SQL database.Try this -
<ma-point-query query="{deviceName:$ctrl.devName, $exact: true}">