(function() {
'use strict';
angular
  .module('myApp')
  .controller("flightListItemCtrl", flightListItemCtrl)
  .directive("flightListItem", flightListItemDirective)

function flightListItemDirective() {
  return {
    bindToController: {
      flight: "=",
      index: "@",
      removeItem: "&"
    },
    scope: true,
    controller: flightListItemCtrl,
    controllerAs: "ctrl",
    templateUrl: "components/flight-list-item.template.html"
  }
}

flightListItemCtrl.$inject = ["$scope", "airports"];

function flightListItemCtrl($scope, airports) {
  var vm = this;

  vm.isEditing = $scope.flight.isNew || false;
  vm.origin = $scope.flight.origin.city + " (" + $scope.flight.origin.code + ")";
  vm.destination = $scope.flight.destination.city + " (" + $scope.flight.destination.code + ")";
  vm.airports = airports;
  vm.departureTimestamp = $scope.flight.departureTimestamp;
  vm.arrivalTimestamp = $scope.flight.arrivalTimestamp;
  vm.airline = $scope.flight.airline;

  vm.startEdit   = function() {
    if (!$scope.isEditing) {
        vm.isEditing = $scope.isEditing = true
    }
  };

  vm.saveChanges = function() {
    delete $scope.flight.isNew;
    vm.isEditing = $scope.isEditing = false;

    // just get the airport code here
    $scope.flight.origin.city = vm.origin.substring(0, vm.origin.length-6) // remove outer braces
    $scope.flight.origin.code = vm.origin.substring(vm.origin.length-4, vm.origin.length-1)
    $scope.flight.origin.coordinates = getAirportCoordinates($scope.flight.origin.code)

    $scope.flight.destination.city = vm.destination.substring(0, vm.destination.length-6) // remove outer braces
    $scope.flight.destination.code = vm.destination.substring(vm.destination.length-4, vm.destination.length-1)
    $scope.flight.destination.coordinates = getAirportCoordinates($scope.flight.destination.code)

    $scope.flight.departureTimestamp = vm.departureTimestamp;
    $scope.flight.arrivalTimestamp = vm.arrivalTimestamp;

    $scope.flight.airline = vm.airline
  };

  vm.outboundRemove = function() {
    this.removeItem()
  };

  function getAirportCoordinates(code) {
    var port = airports.find(function(e,i,a) {
      return e.code == code
    });

    return port.coordinates;
  };
}
})()
@@ -256,26 +256,8 @@
 =%22,%0A
-      index: %22@%22,%0A
     
@@ -467,16 +467,28 @@
 $scope%22,
+ %22$timeout%22,
  %22airpor
@@ -529,16 +529,26 @@
 ($scope,
+ $timeout,
  airport
@@ -1017,62 +1017,63 @@
     
-if (!$scope.isEditing) %7B%0A        vm.isEditing = $scope
+$timeout(function() %7B // for ripple completion%0A      vm
 .isE
@@ -1091,16 +1091,22 @@
 ue%0A    %7D
+, 150)
 %0A  %7D;%0A%0A 
@@ -1132,24 +1132,77 @@
 unction() %7B%0A
+    $timeout(function() %7B // for ripple completion%0A  
     delete $
@@ -1221,24 +1221,26 @@
 .isNew;%0A    
+ 
+ 
 vm.isEditing
@@ -1273,16 +1273,18 @@
 e;%0A%0A    
+  
 // just 
@@ -1309,16 +1309,18 @@
 de here%0A
+  
     $sco
@@ -1401,32 +1401,34 @@
 ve outer braces%0A
+  
     $scope.fligh
@@ -1499,32 +1499,34 @@
 n.length-1)%0A    
+  
 $scope.flight.or
@@ -1586,32 +1586,34 @@
 t.origin.code)%0A%0A
+  
     $scope.fligh
@@ -1709,24 +1709,26 @@
  braces%0A    
+  
 $scope.fligh
@@ -1823,24 +1823,26 @@
 ngth-1)%0A    
+ 
+ 
 $scope.fligh
@@ -1924,24 +1924,26 @@
 .code)%0A%0A    
+  
 $scope.fligh
@@ -1988,24 +1988,26 @@
 estamp;%0A    
+ 
+ 
 $scope.fligh
@@ -2049,24 +2049,26 @@
 stamp;%0A%0A    
+  
 $scope.fligh
@@ -2090,16 +2090,28 @@
 airline%0A
+    %7D, 150)%0A
   %7D;%0A%0A  
@@ -2146,29 +2146,92 @@
 () %7B
-%0A    this.removeItem(
+ // for ripple completion%0A    $timeout(function() %7B%0A      vm.removeItem()%0A    %7D, 150
 )%0A  

Remove unused directive parameters