$scope.$on('msg', function(e, msg)
{
toastr.error("Error. Err-01", "Invalid Login!");
});
This is event handler function in angular 1.How can I convert in to angular 2?
Events are now defined on components themselves. There is no more concept of scope in Angular2...
You can attach handlers on them from the HTML elements:
<my-component (someEvent)="handleEvent($event.value)"></my-component>
or within JavaScript code:
this.myEventEmitter.subscribe(
...
)
Defining the myEventEmitter can be done within a component that way:
@Component({
(...)
})
export class DropdownComponent {
@Output()
myEventEmitter: EventEmitter;
constructor(private elementRef:ElementRef) {
this.myEventEmitter = new EventEmitter();
}
select(value) {
this.myEventEmitter.emit(value);
}
}
Hope it helps you, Thierry
msg? There are different ways in Angular2 but there is no direct translation from your code. There is no$scopeanymore. What problem do you actually try to solve. Can you please elaborate a bit more?