How do I get a value after pipe complete?

孟子易

For example. I want Angular auto update the value (using observable).

// in test.component.ts
ngOnInit(){
  let i = 0;
  this.test = new Observalble<any>((ob) => {
    setInterVal(() => {
      ob.next({
        i: i++,
      })
    },1000);
  });
}

<!-- in test.component.html -->
<p>{{ (test | async).i }}</p> <!-- not work -->
<p>{{ (test.i | async) }}</p> <!-- not work -->
user184994

You'll need to fix your spelling errors first: setInterVal should be setInterval (lower case v), and Observalble should be Observable.

Then, you need to add the null safe operator, as the async result of test will start out undefined, and cause errors if you try get the i property from an undefined value. By adding the ?, it will only try to read i if test | async is not null.

// in test.component.ts
ngOnInit(){
  let i = 0;
  this.test = new Observable<any>((ob) => {
    setInterval(() => {
      ob.next({
        i: i++,
      })
    },1000);
  });
}

<!-- in test.component.html -->
<p>{{ (test | async)?.i }}</p> <!-- not work -->

Here is a StackBlitz demo

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do i set a cell value in javafx tablecell after a drag and drop event is complete?

From Dev

How do I get the value of a textbox after it changes in jQuery?

From Dev

How do I get the current value of a jquery-ui auto-complete using Selenium?

From Dev

How do I use pipe to keep the value that is in a child process?

From Dev

How do I pipe output to date -d "value"?

From Dev

How do I process a notification in gulp after all tasks are complete?

From Dev

How do I pipe a single number to get a list?

From Dev

How do I get the output of jq to pipe to curl

From Dev

How do I get the full MATE desktop after installing Ubuntu? mate-desktop-environment isn't complete

From Dev

How do I store a variable in my controller whose value I get after DOM has loaded?

From Dev

How do I get get the value of a variable?

From Dev

How do I get the value of OWIN cookie right after calling IauthenticationManager.SignIn?

From Dev

How do i get value from Select input using jQuery after DOM has been loaded

From Dev

How do I get value after selected from dropdown menu with Python?

From Dev

How do I get the value of a @ object attribute?

From Dev

How do I get a Scope value in LIferay

From Dev

How do I get the value of the radio button?

From Dev

How do I get an SP return value?

From Dev

How do I get an absolute value in Rust?

From Dev

How do I get a defined value with Qmake?

From Dev

How do I get the value of this xml?

From Dev

How do I get the text and not the value of an Option?

From Dev

How do I get the value in a generic Dictionary?

From Dev

How do i get a value of textField in an UIAlertController?

From Dev

How do I get the current value of a Variable?

From Dev

How do I get the integer value of an enum?

From Dev

how do i get a reference of primitive value?

From Dev

How do i get the value in an anchor tag?

From Dev

How do i get an xml value in perl?

Related Related

  1. 1

    How do i set a cell value in javafx tablecell after a drag and drop event is complete?

  2. 2

    How do I get the value of a textbox after it changes in jQuery?

  3. 3

    How do I get the current value of a jquery-ui auto-complete using Selenium?

  4. 4

    How do I use pipe to keep the value that is in a child process?

  5. 5

    How do I pipe output to date -d "value"?

  6. 6

    How do I process a notification in gulp after all tasks are complete?

  7. 7

    How do I pipe a single number to get a list?

  8. 8

    How do I get the output of jq to pipe to curl

  9. 9

    How do I get the full MATE desktop after installing Ubuntu? mate-desktop-environment isn't complete

  10. 10

    How do I store a variable in my controller whose value I get after DOM has loaded?

  11. 11

    How do I get get the value of a variable?

  12. 12

    How do I get the value of OWIN cookie right after calling IauthenticationManager.SignIn?

  13. 13

    How do i get value from Select input using jQuery after DOM has been loaded

  14. 14

    How do I get value after selected from dropdown menu with Python?

  15. 15

    How do I get the value of a @ object attribute?

  16. 16

    How do I get a Scope value in LIferay

  17. 17

    How do I get the value of the radio button?

  18. 18

    How do I get an SP return value?

  19. 19

    How do I get an absolute value in Rust?

  20. 20

    How do I get a defined value with Qmake?

  21. 21

    How do I get the value of this xml?

  22. 22

    How do I get the text and not the value of an Option?

  23. 23

    How do I get the value in a generic Dictionary?

  24. 24

    How do i get a value of textField in an UIAlertController?

  25. 25

    How do I get the current value of a Variable?

  26. 26

    How do I get the integer value of an enum?

  27. 27

    how do i get a reference of primitive value?

  28. 28

    How do i get the value in an anchor tag?

  29. 29

    How do i get an xml value in perl?

HotTag

Archive