当前位置: 移动技术网 > IT编程>脚本编程>AngularJs > AngularJS中update两次出现$promise属性无法识别的解决方法

AngularJS中update两次出现$promise属性无法识别的解决方法

2018年05月03日  | 移动技术网IT编程  | 我要评论

前言

本文主要介绍的是在angularjs中update两次出现$promise属性无法识别的解决方法,下面话不多说,先来看看错误提示,然后再看看解决的办法吧。

一、错误信息如下:

error 2015-12-02 14:33:17,653 http-bio-8080-exec-42 o.s.s.r.i.e.internalerrorexceptionmapper - unrecognized field "$promise" (class com.inetpsa.fnd.rest.client.clientrepresentation), not marked as ignorable (6 known properties: "lastname", "address", "telephone", "clientid", "mail", "firstname"]) 
 at [source: org.apache.catalina.connector.coyoteinputstream@1b9d797d; line: 1, column: 357] (through reference chain: com.inetpsa.fnd.rest.client.clientrepresentation["$promise"]) 
com.fasterxml.jackson.databind.exc.unrecognizedpropertyexception: unrecognized field "$promise" (class com.inetpsa.fnd.rest.client.clientrepresentation), not marked as ignorable (6 known properties: "lastname", "address", "telephone", "clientid", "mail", "firstname"]) 
 at [source: org.apache.catalina.connector.coyoteinputstream@1b9d797d; line: 1, column: 357] (through reference chain: com.inetpsa.fnd.rest.client.clientrepresentation["$promise"]) 
 at com.fasterxml.jackson.databind.exc.unrecognizedpropertyexception.from(unrecognizedpropertyexception.java:51) ~[jackson-databind-2.4.4.jar:2.4.4] 
 at com.fasterxml.jackson.databind.deserializationcontext.reportunknownproperty(deserializationcontext.java:744) ~[jackson-databind-2.4.4.jar:2.4.4] 
 at com.fasterxml.jackson.databind.deser.std.stddeserializer.handleunknownproperty(stddeserializer.java:915) ~[jackson-databind-2.4.4.jar:2.4.4] 
 at com.fasterxml.jackson.databind.deser.beandeserializerbase.handleunknownproperty(beandeserializerbase.java:1306) ~[jackson-databind-2.4.4.jar:2.4.4] 
 at com.fasterxml.jackson.databind.deser.beandeserializerbase.handleunknownvanilla(beandeserializerbase.java:1284) ~[jackson-databind-2.4.4.jar:2.4.4] 
 at com.fasterxml.jackson.databind.deser.beandeserializer.vanilladeserialize(beandeserializer.java:243) ~[jackson-databind-2.4.4.jar:2.4.4] 
 at com.fasterxml.jackson.databind.deser.beandeserializer.deserialize(beandeserializer.java:118) ~[jackson-databind-2.4.4.jar:2.4.4] 

二、问题代码

angular 自动会在返回的data数据中带上$promise属性。

在进行下面copy时将从data返回的数据copy到当前行用来显示,这样在进行update的操作时带的数据体中就包含了$promise属性,结果就会出现上述错误导致update失败。  

三、更改如下:

// ===============show the update modal dialog ================== 
 $scope.temprowentityforupdate; 
 $scope.openupdateclientpopup=function(){ 
 $scope.form1.$setsubmitted(true); 
 $scope.temprowentityforupdate = {}; 
 angular.copy($scope.currentselectedrowentity, $scope.temprowentityforupdate); 
 angular.element('#updatedialog').modal({ 
 backdrop: false 
 }); 
 
 }; 
 
 $scope.updateclient=function(){ 
 if($scope.form1.$submitted && $scope.form1.$valid){ 
 client.update({},$scope.temprowentityforupdate,function(){ 
  angular.copy($scope.temprowentityforupdate,$scope.currentselectedrowentity); 
 }); 
 
 angular.element('#updatedialog').modal('hide'); 
 } 
 }; 

解决办法:不使用更新后获得的data数据,而是从当前的行模型中取得数据copy给当前选中的行即可。

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网