thank you Gunter and Eudes!
Just in case someone else comes across this question, I have posted some
edits to the code to ensure that it works.
------------------------------------- /components/myoutput.ts
-----------------------------------------
import {Component, Output, EventEmitter} from 'angular2/core';
@Component({
selector: 'my-output',
template: '<div>my output</div>'
})
export class MyOutput{
@Output() someFieldChange: EventEmitter<string> = new EventEmitter();
ngOnInit() {
this.someFieldChange.emit('someText');
}
}
------------------------------------ /components/myconsumer.ts
--------------------------------------
import {Component} from 'angular2/core';
import {MyOutput} from './myoutput';
@Component({
selector: 'my-consumer',
template: '<div>my consumer</div><my-output
(someFieldChange)="onFieldChange($event)"></my-output>',
directives: [MyOutput]
})
export class MyConsumer{
constructor() {}
ngOnInit() {}
onFieldChange(event:any) {
console.log(event);
}
}
----------------------------------------- app.ts
------------------------------------------------------
import {Component} from 'angular2/core';
import {MyOutput} from './components/myconsumer';
@Component({
selector: 'app',
template: '<div>the app root</div><my-consumer></my-consumer>',
directives: [ MyConsumer ]
})
export class App {}
---------------------------------------------------------------------
...and then bootstrap the app in whatever manner you feel works best for you
The problem I ran into with the angular.io example in the docs was that it was
using a @Directive decorator?
On Monday, January 11, 2016 at 7:07:17 PM UTC-5, michael corbridge wrote:
>
> Does anyone have a link to an example showing the use of the @Output
> decorator in a component? I have been working with the example in
> angular.io, and I cannot seem to get anything to output to the console
> (much to my frustration)
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.