What is a dehydrated detector and how am I using one here?

Fisu

I'm using a simple directive to focus a text input when the element is active using *ngIf. This is contained within a *ngFor loop.

When the first *ngIf is activated, the input focuses as expected. When another input is activated I get the error:

EXCEPTION: Attempt to use a dehydrated detector.

I don't understand what this means and how I can prevent the error. The functionality still works even with the error.

@Directive({
    selector: '[myAutoFocus]'
})
export class AutoFocusDirective {
    constructor(private elem: ElementRef) {
        window.setTimeout(function() {
            elem.nativeElement.querySelector('input').focus();
        });
    }
}

```

Tomas Holas

Dehydrated detector is a component that has been removed from the change detection system, usually because it has been unmounted from DOM by *ngIf or other means: If there's an asynchronous action in the application that hits this already unmounted detector, error is thrown: solution is to use [hidden] instead of *ngIf on the affected component, or defer the offending action to next tick using setTimeout( () => this.offendingAction(), 0)

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

What am I accomplishing using generics?

分類Dev

What am I missing when using PROGMEM?

分類Dev

What DNS servers am I using?

分類Dev

here i am getting await can only use inside async function error but i am using async in my function

分類Dev

here i am getting await can only use inside async function error but i am using async in my function

分類Dev

How to move view using gesture detector and animation

分類Dev

How to check the datatable version I am using

分類Dev

How efficient am I using these tables in lua?

分類Dev

How would I avoid using a goto statement here?

分類Dev

What Version of Foundation Am I using? (NodeJS/Grunt)

分類Dev

Am I using '&&' incorrectly?

分類Dev

If I have uninstalled Adobe Reader, but I can still open PDFs in Chrome, what application am I using?

分類Dev

Ubuntu OpenStack and What Did I Miss Here?

分類Dev

Using Kafka-Go, why am I seeing what appears to be batching reads/writes? Is there a config I am missing?

分類Dev

Hive - How to know which execution engine I am currently using

分類Dev

How to call method at App start if I am using provider?

分類Dev

How to know which platform I am using in lubuntu, ubuntu or kubuntu

分類Dev

I just add two alias name for the same remote repo on Git. How can I delete one of them? Here is my code

分類Dev

In C++, am I paying for what I am not eating?

分類Dev

Am I guaranteed to have exactly one JavaVM per process using JNI?

分類Dev

How do I correctly install pyinstaller? (what am I doing wrong?)

分類Dev

What am I doing wrong, how do I add an interstitial ad

分類Dev

implement Unsubscribe link in newsletter, what is the internal functionality as i am using amazon SES to send emails

分類Dev

Using find -name with tar in a bash script, what am i doing wrong?

分類Dev

I am trying to push a directory to a server using rsync. What is wrong with this command?

分類Dev

What's wrong with this angular js code ( I am using this instead of scope in controllers)

分類Dev

Am I using 'zypper' correctly?

分類Dev

I am trying to create a bubble sort visualization but I ran into a probem on how do to animate in a one-by-one fashion

分類Dev

Is there a container like the one I am asking for?

Related 関連記事

  1. 1

    What am I accomplishing using generics?

  2. 2

    What am I missing when using PROGMEM?

  3. 3

    What DNS servers am I using?

  4. 4

    here i am getting await can only use inside async function error but i am using async in my function

  5. 5

    here i am getting await can only use inside async function error but i am using async in my function

  6. 6

    How to move view using gesture detector and animation

  7. 7

    How to check the datatable version I am using

  8. 8

    How efficient am I using these tables in lua?

  9. 9

    How would I avoid using a goto statement here?

  10. 10

    What Version of Foundation Am I using? (NodeJS/Grunt)

  11. 11

    Am I using '&&' incorrectly?

  12. 12

    If I have uninstalled Adobe Reader, but I can still open PDFs in Chrome, what application am I using?

  13. 13

    Ubuntu OpenStack and What Did I Miss Here?

  14. 14

    Using Kafka-Go, why am I seeing what appears to be batching reads/writes? Is there a config I am missing?

  15. 15

    Hive - How to know which execution engine I am currently using

  16. 16

    How to call method at App start if I am using provider?

  17. 17

    How to know which platform I am using in lubuntu, ubuntu or kubuntu

  18. 18

    I just add two alias name for the same remote repo on Git. How can I delete one of them? Here is my code

  19. 19

    In C++, am I paying for what I am not eating?

  20. 20

    Am I guaranteed to have exactly one JavaVM per process using JNI?

  21. 21

    How do I correctly install pyinstaller? (what am I doing wrong?)

  22. 22

    What am I doing wrong, how do I add an interstitial ad

  23. 23

    implement Unsubscribe link in newsletter, what is the internal functionality as i am using amazon SES to send emails

  24. 24

    Using find -name with tar in a bash script, what am i doing wrong?

  25. 25

    I am trying to push a directory to a server using rsync. What is wrong with this command?

  26. 26

    What's wrong with this angular js code ( I am using this instead of scope in controllers)

  27. 27

    Am I using 'zypper' correctly?

  28. 28

    I am trying to create a bubble sort visualization but I ran into a probem on how do to animate in a one-by-one fashion

  29. 29

    Is there a container like the one I am asking for?

ホットタグ

アーカイブ