简体   繁体   English

Javascript / Angular - JS Object的属性和方法

[英]Javascript/Angular - Properties and methods of JS Object

JavaScript objects are containers for named values called properties or methods, but I want to know if when I send some object into a $http.post of Angular, does it recognize only the properties? JavaScript对象是名为属性或方法的命名值的容器,但我想知道当我将一些对象发送到Angular的$ http.post时,它是否只识别属性?

Reference: https://www.w3schools.com/js/js_objects.asp Example of what I mean: 参考: https//www.w3schools.com/js/js_objects.asp我的意思是:

//TestFactory // TestFactory中

return function(){
        {name: 'test1', getName :  function(){ return this.name }
       };

//TestController //的TestController

vm.Test = new TestFactory();
TestService.Save(vm.Test);

//TestService // TestService的

function Save(testdata){
 $http.post('url/test/save', testdata)
}

To see what the post payload will be, you can 要查看帖子有效负载的内容,您可以

console.log( JSON.stringify( test_data ) );

You'll see something like this 你会看到这样的东西

{
  'name': 'test1',
  'getName': '[Function]'
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM