"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
// Angular-Importe
var core_1 = require('@angular/core');
var router_1 = require('@angular/router');
var FlugService_1 = require('../Services/FlugService');
var Flugliste = (function () {
    function Flugliste(flugService, router, differs, ref) {
        this.flugService = flugService;
        this.router = router;
        this.differs = differs;
        this.ref = ref;
        this.differ = differs.find({}).create(null);
    }
    Flugliste.prototype.ngOnInit = function () {
        this.DatenLaden();
    };
    // nur zur Diagnose!
    Flugliste.prototype.ngOnChanges = function (changes) {
        console.log('ngDoCheck: Change detected:', changes);
    };
    // nur zur Diagnose!
    Flugliste.prototype.ngDoCheck = function () {
        var changes = this.differ.diff(this.flugSet);
        if (changes) {
            console.log('ngDoCheck: changes detected', changes);
        }
        else {
            console.log('ngDoCheck: nothing changed');
        }
    };
    Flugliste.prototype.DatenLaden = function () {
        var _this = this;
        this.flugService.getAll(function (daten) {
            _this.flugSet = FlugService_1.FlugService.flugSet;
            _this.status = _this.flugSet.length + " Flüge geladen.";
            // oder wenn Observable hochgereicht wird: 
            // this.flugService.getAll().subscribe(x => {  this.flugSet =x; console.log("subscribe...", x);} );
        });
    };
    Flugliste.prototype.Loeschen = function (flug) {
        this.flugService.delete(flug);
        this.flugSet = FlugService_1.FlugService.flugSet;
        this.status = "Flug " + flug.FlugNr + " gel\u00F6scht!";
        console.log("delete(): " + this.flugSet.length);
    };
    Flugliste.prototype.onDatenGeaendertEvent = function (flug) {
        console.log("EVENT: Flug geändert", flug);
        this.flugSet = FlugService_1.FlugService.flugSet;
    };
    Flugliste.prototype.Aendern = function (flug) {
        var link = ['/edit', flug.FlugNr];
        this.router.navigate(link);
    };
    Flugliste = __decorate([
        // für Event
        core_1.Component({
            selector: 'Flugliste',
            templateUrl: 'App/Flugliste/Flugliste.html',
            changeDetection: core_1.ChangeDetectionStrategy.Default,
            providers: [FlugService_1.FlugService] // Lokale Registrierung eines Dienstes für Dependency Injection
        }), 
        __metadata('design:paramtypes', [FlugService_1.FlugService, router_1.Router, core_1.KeyValueDiffers, core_1.ChangeDetectorRef])
    ], Flugliste);
    return Flugliste;
}());
exports.Flugliste = Flugliste;
//# sourceMappingURL=Flugliste.js.map