Pregunta

I've got a piece of code that looks like this:

$scope.renameUser = function(key,name) {
  console.log('renameUser, key: ', key);
  console.log('renameUser, name: ', name);
  var userOne = $scope.users.$key(key);
  userOne.$key('displayName').$set(name);
};

It works, but you need to reload the page to see the updated result. I would like it to update instantly.

During debugging I added this part, but I never get it to trigger... Any ideas what is going on?

$scope.users.$on('set', opts, function(value) {
   console.log(value);
});
¿Fue útil?

Solución

This issue was introduced in v3.2.0. The $key method, whether it's being called on a model returned by a $goQuery or $goKey should return a 'new' model associated with a 'relative' key. Instead it was recycling the service associated with the first key used.

This issue has been fixed in v3.2.2, upgrading to this version should resolve your issue.

Thanks for sharing!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top