Aurelia prints __observers__ instead of an object

I am trying to associate an object with a view model to see the following:

// welcome.js
export class Welcome {

constructor() {
    this.data = {
        a: "",
        b: "",
        c: ""
    }
}

submit() {
       console.log(this.data);
    }
}


// welcome.html
<form role="form" submit.delegate="submit()">
    <div class="form-group">
      <textarea class="form-control" value.bind="data.a" rows="3"></textarea>
    </div>
    <button type="submit" class="btn btn-default">Submit</button>
</form>

Ideally, it should print only the object data. However, it prints the following output to the console.

enter image description here

I would like to know what an object is observersand how I can access only the object data. Thank.

+1
source share
2 answers

Short answer:

An object __observers__is what makes detection of Aurelia changes possible; you cannot get rid of it. If you really need to extract exactly what you want, you need to do it manually.

Bit more depth

, viewmodel, , , . - , , , 1.

, , - - , (${ data.a }) (<input value.bind="data.a" />) .. - , Aurelia , , , , .

- 1 - , . , Aurelia, , , x = 1 ( ), get-set Java (setX(1)), , , , . , , Aurelia , .

. , .


, , , . , Angular , Angular , , - :

Angular . , , HTTP, , .

, , , , :

setTimeout(() => this.someVal = 0, 0);

- .


, , , - . - Aurelia, - Angular.

Aurelia , , .

Angular, , , , .

+3

, : console.log(JSON.parse(JSON.stringify(this.data)))

+1

Source: https://habr.com/ru/post/1683598/


All Articles