AnsweredAssumed Answered

AngularJS "ng-click" no update

Question asked by HansBleijendaal on Sep 25, 2017
Latest reply on Sep 25, 2017 by Roger Palmen

I am a new-bee in angularJS programming.

I created an application that fetches the snapshotvalues from 10 Integer points from the PI-Archive. The page loads with the 10 snapshot values but whatever I try, the refresh button to does not work like I expect.

It is all pretty straitforward and standard code, see attachments...

 

What I found out that it has todo with the cached-data: when de debugger in IE-browser is activate I get updates when i pudh the refresh button: Apparently the browser disables the cache.

Another is when I add a timestamp to the webApiCall then I get also data, see code snippet. THis tricks Angular because the URL is everytime different.

 

 

    piWebApiHttpServiceFactory.getSnapshotValue = function (webId) {

        alert(Date())

        return $http.get(serviceBase + 'streams/' + webId + '/value?t=' + Date()).then(function (response) {

            return response; 

       }); 

    };

 

My conclusion is that AngularJS does not get new data when the URL is not changed. But even when the URL does not change I want a refresh because the data can be changed.

My question is: How to force Angular to get always the data, even when the url does not change...

 

Attached: 3 application files.

Attachments

Outcomes