Ganbin Ganbin - 1 year ago 62
AngularJS Question

How to refresh an entity before it is saved, with angular-wakanda API

Before we used to have a

method to refresh the entity, with the WAF. It triggers the
event server side.

I don't see any way to do that now with the angular-wakanda connector.

Am I missing something?

How can I initialize some data for a newly created entity before saving it with the Angular-Wakanda connector?

Answer Source

Version 1.1.0 and higher (from 5/11/16)

With version 1.1.0 and higher, you have to use $recompute() method, that do the same stuff as old (see below) $serverRefresh() method.

You can find its documentation on Angular-Wakanda Entity API Reference.

Version <1.1.0

On the current version (1.0.4) of Angular-Wakanda, you still can do that by calling $serverRefresh() on your entity.

var entity = ds.Product.$create();
entity.$serverRefresh().$promise.then(function () {
  //Your entity is updated with calculated attributes filled, and right events executed

What $serverRefresh() does is the following:

  • On a newly created attribute (not saved yet), it will trigger init then clientrefresh events server-side, then update the client-side entity
  • On an already saved entity, it will trigger clientrefresh event server-side, then update client-side entity

Indeed, it's deprecated and will be removed. But, it will be replaced on 1.1.0 version by another, well-documented and non-ambiguous, method that will have the same behavior.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download