Q:

Return after async function in Angular

I'm writing project using Angular and RxJS. I implemented injectable class that retrieves data from JSON like this: 
import {Injectable, Inject} from '@angular/core';
import {Http} from '@angular/http';
import 'rxjs/add/operator/map';

import {Student} from './student.data';

@Injectable()
export class RosterService {
    private students : Student[];
    constructor(@Inject(Http) private http:Http){}

    private getStudents(){
        this.http.get('/JSON/students.json')
            .map(data => data.json().students)
            .subscribe(data => this.students = data);
    }

    public getRoster() {
        this.getStudents();
        return this.students;
    }
}

After I inject RosterService into constructor of AppComponent (including into @Component as provider):
export class AppComponent {
    public students : Student[];
    constructor(private _rosterService : RosterService) {
        this.students = _rosterService.getRoster();
    }
 }

But when I call getRoaster() method, it doesn't wait until getStudents (async get call) is executed. In the result I get undefined value.
How can I deal with it? Thanks for responce.

A:

I would use call back function, for example if it is a promise then i would use something like below.
var data;
asyncCall().then((result:any) => {
data = reuslt;
return data;
});

Not sure if that's what your looking for. 
Updated:
        @Injectable()
    export class RosterService {
        private students : Student[];
        constructor(@Inject(Http) private http:Http){}

        private getStudents(){
            return this.http.get('/JSON/students.json')
                .map(data => data.json().students)
                .subscribe(data => this.students = data);
        }

        public getRoster() {
           return this.getStudents().then (() =>{
    return this.students;
           });        
         }
       }

And inside your AppComponent 
export class AppComponent {
    public students : Student[];
    constructor(private _rosterService : RosterService) {
        this._rosterService.getRoster().then ((data:<T>)=>{
        this.students =data;
     });
    }
 }

