<repo_name>ao-lab/angularjs-dev-media<file_sep>/15-Acesso-a-dados-usando-$resource/controllers.js
app.controller('IndexController', ['$scope', 'Livros', function ($scope, Livros) {

    $scope.list = function () {

        Livros.get(function (data) {
            console.log(data);
        });

    };

    $scope.read = function (id) {

        Livros.get({id: id}, function (data) {
            console.log(data);
        });

    };

    $scope.save = function () {

        var Livro = {
            "id" : 40,
            "titulo" : "Curso de AngularJS",
        };

        Livros.save({}, Livro);

    };

}]);<file_sep>/12-Diretivas-basicas/controllers.js
app.controller('IndexController', ['$scope', function ($scope) {

    $scope.x = false;
    $scope.html = 'Usamos <b>angular-sanitize</b> para imprimir HTML.';
    $scope.myClass = 'text-info';
    $scope.myImage = 'http://placehold.it/50x50/000';

}]);<file_sep>/07-Loops-usando-ngRepeat/controllers.js
app.controller('IndexController', ['$scope', function ($scope) {

    $scope.users = [];
    $scope.users.push({status: 'true', name: 'Neto', age: '58'});
    $scope.users.push({status: 'true', name: 'Ceni', age: '50'});
    $scope.users.push({status: 'true', name: 'Paulo', age: '30'});
    $scope.users.push({status: 'true', name: 'Farliene', age: '28'});
    $scope.users.push({status: 'true', name: 'Alex', age: '26'});
    $scope.users.push({status: 'true', name: 'Keliene', age: '25'});
    $scope.users.push({status: 'true', name: 'Lainy', age: '22'});
    $scope.users.push({status: 'true', name: 'Dandara', age: '12'});

    $scope.add = function () {
        $scope.users.push({status: 'true', name: $scope.f.name, age: $scope.f.age});
        $scope.cls();
    };

    $scope.cls = function () {
        $scope.f.name = '';
        $scope.f.age = '';
    };

}]);<file_sep>/11-ngRoute/modules.js
var app = angular.module('app', ['ngRoute']);

app.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {

    $routeProvider.when('/', {
        controller: 'HomeController',
        'templateUrl': 'views/home.html'

    }).when('/products', {
        controller: 'ProductsController',
        'templateUrl': 'views/products.html'

    }).when('/products/:id', {
        controller: 'ProductsShowController',
        'templateUrl': 'views/product.html'

    }).otherwise({
        redirectTo: '/'
    });

    $locationProvider.html5Mode(true);

}]);<file_sep>/26-AngularUI-ui.bootstrap/app.js
var app = angular.module('app', ['ngAnimate', 'ui.bootstrap']);

app.controller('IndexController', ['$scope', function ($scope) {

    $scope.accordions = [
        {heading: 'Título Dinâmico 1', body: 'Conteudo Dinâmico 1'},
        {heading: 'Título Dinâmico 2', body: 'Conteudo Dinâmico 2'}
    ];

    $scope.create = function (acc) {
        $scope.accordions.push(acc);
        $scope.acc = {heading: '', body: ''};
    };

}]);<file_sep>/09-Service-e-Factory/controllers.js
app.controller('SumController', ['$scope', 'MathService', function ($scope, MathService) {

    console.log(MathService.sum(10, 5));

}]);

app.controller('SubController', ['$scope', 'MathService', 'User', function ($scope, MathService, User) {

    console.log(MathService.sub(10, 5));
    $scope.user = new User();

}]);

app.controller('UserController', ['$scope', 'User', function ($scope, User) {

    $scope.user = new User();

}]);<file_sep>/11-ngRoute/controllers.js
app.controller('IndexController', ['$scope', '$route', '$routeParams', '$location', function ($scope, $route, $routeParams, $location) {

    $scope.$route = $route;
    $scope.$routeParams = $routeParams;
    $scope.$location = $location;

}]).controller('HomeController', ['$scope', function ($scope) {

    console.log('Tela inicial...');

}]).controller('ProductsController', ['$scope', function ($scope) {

    console.log('Lista de Produtos...');

}]).controller('ProductsShowController', ['$scope', '$routeParams', function ($scope, $routeParams) {

    $scope.params = $routeParams;

    console.log('Produto ' + $scope.params.id + '...');

}]);<file_sep>/22-AngularUI-ui.highlight-e-ui.mask/app.js
var app = angular.module('app', ['ngSanitize', 'ui.mask', 'ui.highlight']);

app.controller('IndexController', ['$scope', function ($scope) {

    $scope.text = 'Será que vai funcionar!';

    $scope.maskCpf = '999.999.999-99';
    $scope.maskPhone = '(99) 9999-9999';

    // 9 - somente numeros
    // A - somente letras
    // * - qualquer coisa

}]);<file_sep>/18-$location/app.js
var app = angular.module('app', []);

app.controller('IndexController', ['$scope', '$location', function ($scope, $location) {

    $scope.$location = $location;

    $scope.see = function (id) {
        console.log('Entrou no id ' + id);
        $location.search({id: id});
    };

    $scope.$watch('$location.search().id', function (id) {
        console.log('Mudou para id ' + id);
    });

}]);

app.config(['$locationProvider', function ($locationProvider) {

    $locationProvider.html5Mode({
        enabled: true, requireBase: false
    }).hashPrefix('#');

    //$locationProvider.html5Mode(true);

}]);
<file_sep>/16-AngularJS-vs-jQuery/controllers.js
app.directive('tooltip', function () {

    return {
        restrict: 'ACE',
        link: function (scope, element, attr) {

            element.attr('container', 'body');
            element.attr('data-placement', attr.tooltip);
            element.tooltip({'html': true});

        }
    };

});

app.controller('IndexController', ['$scope', function ($scope) {


}]);<file_sep>/14-Requisicoes-assincronas-usando-$http/controllers.js
app.controller('IndexController', ['$scope', '$http', function ($scope, $http) {

    $scope.data = [];

    $scope.list = function () {
        $http.get('data.json').success(function (data) {
            $scope.data = data;
        }).error(function () {
            alert('Erro ao tentar ler data.json');
        });
    };

    //------------------------------------------------------------------------------------------------------------------

    $scope.icon = '';
    $scope.description = '';
    $scope.city = 'Brasília';
    $scope.server = 'http://api.openweathermap.org/data/2.5/weather?appid=2de143494c0b295cca9337e1e96b00e0&units=metric&q=';
    $scope.weather = [];

    $scope.search = function () {
        $http.get($scope.server + $scope.city).success(function (data) {
            $scope.weather = data;

            $scope.icon = data.weather[0].icon;
            $scope.description = data.weather[0].description;

        }).error(function () {
            alert('Erro ao tentar ler data.json');
        });
    };

}]);<file_sep>/09-Service-e-Factory/factories.js
app.factory('User', function () {

    console.log('Criando UserFactory....');

    var User = function () {

        console.log('Instanciando UserFactory....');

        this.name = 'Alex';
        this.age = '25';
        this.hello = function () {
            return 'Olá ' + this.name + '!';
        };
    };

    return User;

});<file_sep>/09-Service-e-Factory/services.js
app.service('MathService', [function () {

    console.log('Criando MathService....');

    this.sum = function (v1, v2) {
        console.log('Somando com MathService....');
        return v1 + v2;
    };

    this.sub = function (v1, v2) {
        console.log('Subtraindo com MathService....');
        return v1 - v2;
    };

}]);<file_sep>/17-Animations/app.js
var app = angular.module('app', ['ngAnimate']);

app.controller('IndexController', ['$scope', function ($scope) {

    $scope.items = [1, 2, 3, 4, 5];

    $scope.add = function () {
        if ($scope.items.indexOf($scope.item) == -1) {
            $scope.items.push($scope.item);
        }
    };

}]);<file_sep>/20-Plugins/app.js
var app = angular.module('app', ['pascalprecht.translate']);

app.config(['$translateProvider', function ($translateProvider) {

    $translateProvider.translations('pt-BR', {
        TITLE: 'Seja Bem-Vindo!',
        DESCRIPTION: 'Página Inicial.',
        BTN_OK: 'Botão OK',
        BTN_CANCEL: 'Botão CANCELAR',
        BTN_ENGLISH: 'English',
        BTN_PORTUGUESE: 'Português'
    });

    $translateProvider.translations('en', {
        TITLE: 'Wellcome!',
        DESCRIPTION: 'First Page.',
        BTN_OK: 'OK Button',
        BTN_CANCEL: 'CANCEL Button',
        BTN_ENGLISH: 'English',
        BTN_PORTUGUESE: 'Português'
    });

    $translateProvider.preferredLanguage('en');

}]);

app.controller('IndexController', ['$scope', '$translate', function ($scope, $translate) {

    $scope.lang = function (lang) {
        $translate.use(lang);
    };

}]);<file_sep>/15-Acesso-a-dados-usando-$resource/modules.js
var app = angular.module('app', ['ngResource']);

app.factory('Livros', ['$resource', function ($resource) {

    var server = 'http://parceiros.bomaluno.loc/beneficios/:id';

    return $resource(server, {id: '@id'});

}]);<file_sep>/api/upload.php
<?php

if (!empty($_FILES)) {

    $source = $_FILES['file']['tmp_name'];
    $new = __DIR__ . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . $_FILES['file']['name'];

    move_uploaded_file($source, $new);

    echo json_encode(['answer' => 'File transfer completed.']);

} else {

    echo json_encode(['answer' => 'No files!']);

}<file_sep>/24-AngularUI-Google-Maps/app.js
var app = angular.module('app', ['uiGmapgoogle-maps']);

//app.config(['uiGmapGoogleMapApiProvider', function (GoogleMapApiProviders) {
//
//    GoogleMapApiProviders.configure({
//        china: true
//    });
//
//}]);

app.controller('IndexController', ['$scope', function ($scope) {

    $scope.map = {
        zoom: 12,
        center: {
            latitude: -15.8,
            longitude: -47.9
        }
    };

    $scope.marker = {
        id: 0,
        coords: $scope.map.center
    };

}]);

<file_sep>/10-Filter/filters.js
app.filter('Hello', function () {

    return function (name) {
        return 'Olá ' + name + ' !';
    }

});