//  //OLD
// function simpleController($scope) {
//     $scope.customers =[
//         {name:'John Smith', city : 'Ottawa'},
//         {name:'Dave Johnson', city : 'Pensilvenia'},
//         {name:'Jane Doe', city : 'New York'}
//     ]
// }


var myapp = angular.module('testApp',["ngRoute", "ngAnimate"]);

//dependency injection
//var myappDependency = angular.module('testApp', ['helperModule']);


// var controllers = {}; // for multiple controllers


myapp.factory('simpleFactory', function () {
    var factory = {}; // empty object
    var facData = [{name : 'asd'}];
    var asd = "asd";

    factory.sendData = function () {
        return asd;
    }

    // for a service, instead of the object factory, we use $this.sendData = function () {....}

    return factory;

});


myapp.controller('simpleController', function($scope,simpleFactory) {
    $scope.customers =[
        {name:'John Smith', city : 'Ottawa'},
        {name:'Dave Johnson', city : 'Pensilvenia'},
        {name:'Jane Doe', city : 'New York'}
    ];
    $scope.a = "\"A\" from controller";

    $scope.fac = simpleFactory.sendData();


    $scope.addCustomer = function () {
        $scope.customers.push({
            name: $scope.newCustomer.name,
            city: $scope.newCustomer.city
        })
    }
});







// controllers.secondController = function ($scope) {
//     $scope.sponsors = [
//         {name : 'Bershka'},
//         {name : 'Zara'},
//         {name : 'Kaki'},
//         {name:  'U-man'}
//     ];
// }
//myapp.controller(controllers);
