I'm searching a way for execute a external function in the main component of angular like this:
<head>
<script>
System.import('app').catch(function(err){ console.error(err); });
function callback(datos){
alert("datos: "+datos);
}
</script>
</head>
<!-- 3. Display the application -->
<body>
<my-app [cb]="callback">loading...</my-app>
</body>
And call this in the component like this:
import { Component,Input } from '@angular/core';
@Component({
selector: 'my-app',
template: '<h1 (click)="cb()">My First Angular 2 App</h1>'
})
export class AppComponent {
@Input() cb;
}
But it doesn't work. Somebody know a way to do this?
Thanks in advance.