Last active
October 11, 2019 11:07
-
-
Save guaracyalima/c1520ff3536cb1c288f913feba694f4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script> | |
<body> | |
<script> | |
angular.module("meuViadinhoFavoritoApp", []); | |
angular.controller("myCtrl", function ($scope) { | |
vm = this; | |
vm.data1 = '06.09.2019'; | |
vm.data2 = '2019-09-03-12.22.10.484160'; | |
//Desabilita o input | |
//variaveis dos models e do ng-disabled pra controlar | |
vm.cachuleta; | |
vm.cachuletad = false; | |
vm.saboque; | |
vm.saboqued = false; | |
//funções que habilita e desabilita, n coloque no input pq quando ele é desabilitado é como se | |
//nem existisem mais | |
//coloca o ng-disabled num elemento mais acima | |
vm.desabilitaSaboque = function () { | |
$scope.saboqued = true; | |
$scope.saboque = ''; | |
$scope.cachuletad = false; | |
} | |
vm.desabilitaCachuleta = function () { | |
$scope.cachuleta = ''; | |
$scope.cachuletad = true; | |
$scope.saboqued = false; | |
} | |
//até aqui só | |
}); | |
//filtros que formatam as datas | |
angular.filter('dataComTimestamps', function () { | |
return function (input) { | |
var ano = input.substring(0, 4); | |
var mes = input.substring(5, 7); | |
var dia = input.substring(8, 10); | |
var dataFormatada = dia + '/' + mes + '/' + ano; | |
return dataFormatada; | |
} | |
}) | |
angular.filter('asDataComPontos', function () { | |
return function (input) { | |
input = input.replace('.', '/'); | |
input = input.replace('.', '/'); | |
return input; | |
} | |
}); | |
</script> | |
<div ng-app="meuViadinhoFavoritoApp" ng-controller="myCtrl as vm"> | |
<br> | |
<h1>{{ vm.data1 | asDataComPontos }}</h1> | |
<br> | |
<h2>{{ vm.data2 | dataComTimestamps }}</h2> | |
<br> | |
<br> | |
<br> | |
<div ng-click="vm.desabilitaSaboque()"> | |
<label for="cachuleta">cachuleta {{ vm.cachuletad }} </label> | |
<input type="text" name="cachuleta" id="cachuleta" ng-model="vm.cachuleta" ng-disabled="vm.cachuletad"> | |
</div> | |
<br> | |
<br> | |
<div ng-click="vm.desabilitaCachuleta()"> | |
<label for="saboque">saboque {{ vm.saboqued }} </label> | |
<input type="text" name="saboque" id="saboque" ng-model="vm.saboque" ng-disabled="vm.saboqued"> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment