File size: 764 Bytes
7e79d67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(function () {
    'use strict'
    function CreateTripController($location, identity, trips, notifier, cities) {
        var vm = this;
        if (!identity.isAuthenticated()) {
            $location.path('/unauthorized');
        }
        vm.createTrip = function (trip) {
            debugger;
            trips.createTrip(trip)
            .then(function (res) {
                notifier.success('You have succesfully created trip');
                $location.path('/trips');
            })
        }
        cities.getAll()
        .then(function (res) {
            vm.cities = res;
        })

    }
    angular.module('myApp')
    .controller('CreateTripController', ['$location', 'identity', 'trips', 'notifier', 'cities', CreateTripController])
}())