1

I get a strange error when using @Output

Output declaration

@Output() change: EventEmitter = new EventEmitter();

Emitting Value

this.change.emit('string');

Event listener

<selective (change)="getDataAreas($event)"></selective>

Do I forget someting?

When I add the last command (change) I always get this error to the console

TypeError: instance[output.propName].subscribe is not a function

FYI

The emit is inside this code

this.sub = this.searchField.valueChanges
        .startWith('')
        .debounceTime(200)
        .subscribe((result) => {
            this.change.emit(result);
        });
10
  • What is this.searchField.valueChanges? Commented May 11, 2017 at 5:51
  • this.searchField = new FormControl(); Commented May 11, 2017 at 5:52
  • I don't have problems with the observable. It works as I expect... Commented May 11, 2017 at 5:54
  • 1
    In which component do you define the @Output() change? Can you give more detail or maybe share the code of these 2 components (listener and emitter)? Commented May 11, 2017 at 5:55
  • Selective Component Commented May 11, 2017 at 5:56

1 Answer 1

4

I found it...

PHP Storm auto generate wrong import path

import {EventEmitter} from "events"; // Wrong

import {EventEmitter} from '@angular/core'; // Right
Sign up to request clarification or add additional context in comments.

1 Comment

PHP Storm does ask you before it adds the import statement. You should wisely select which one to use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.