1
I have three tabs with content. Every interaction with the fields is controlled by Angularjs.
I need to clear the fields after changing tab (by clicking).
How can I do that?
Html Code
<!DOCTYPE html>
<html>
<head>
<title>
Criando Abas
</title>
<meta charset="UTF-8" />
<style type="text/css">
.abas {
position: relative;
}
.aba {
display: inline;
}
.aba > a {
float: left;
padding: 0.5em 1em;
background: linear-gradient(#FFF, #EEE);
border-width: 1px;
border-style: solid;
border-color: #CCC #CCC #FFF;
border-top-right-radius: 8px;
border-top-left-radius: 8px;
}
.aba:not(:target) a {
border-bottom: 0 none;
}
.aba:target a, a:hover {
background: white;
}
.conteudo {
position: absolute;
left: 0;
top: calc(2em + 4px); /* altura do link + bordas */
z-index: -2;
border: 1px solid #CCC;
background-color: white;
}
.aba:target .conteudo {
z-index: -1;
}
</style>
</head>
<body>
<!-- Criando a listagem -->
<ul class="abas">
<!-- Aqui, criação da primeira aba -->
<li class="aba" id="aba-1">
<a href="#aba-1">Aba1</a>
<section class="conteudo"> Conteúdo da Aba 1 </section></li>
<!-- Aqui, criação da segunda aba -->
<li class="aba" id="aba-2">
<a href="#aba-2">Aba 2</a>
<section class="conteudo"> Conteúdo da Aba 2 </section></li>
<!-- Aqui, criação da terceira aba -->
<li class="aba" id="aba-3">
<a href="#aba-3">Aba 3</a>
<section class="conteudo"> Conteúdo da Aba 3 </section></li>
</ul>
</body>
</html>
Javascript code
angular.module('xxxx').controller('xxxController', function ($scope) {
var m = $scope;
m.validarAba1 = function(){
$scope.message = "TESTE1";
};
m.validarAba2 = function(){
$scope.message = "TESTE2";
};
m.validarAba3 = function(){
$scope.message = "TESTE3";
};
}
Your fields are linked to a certain class?
– André Luis Marmo
OK. Each field is linked to a class. And each tab has its class..
– alexjosesilva
I took the Java tag because I think you confused it with Javascript.
– Jéf Bueno
Something like $Scope.Aba.Field = '' wouldn’t work? I don’t know what your controller’s structure looks like.
– André Luis Marmo
There are several fields...Who controls validations is the Angularjs....
– alexjosesilva