-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteste4.html
More file actions
59 lines (48 loc) · 1.46 KB
/
Copy pathteste4.html
File metadata and controls
59 lines (48 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js"></script>
<meta charset="UTF-8">
</head>
<body>
<input type="search" ng-model="busca">
<div ng-controller="CtrlApp">
total <b>{{pessoas.length}}</b>
<ul>
<li ng-repeat="pessoa in pessoas | filter:busca">
{{pessoa.nome}}, {{pessoa.cidade}}
<button ng-click="remover($index)">Remover</button>
</li>
</ul>
<div>
Nome:<input type="text" ng-model="vName">
<br>
Cidade:<input type="text" ng-model="vCidade">
<button ng-click="adicionar()">Adicionar</button>
</div>
</div>
</body>
<script>
var myApp = angular.module('app', []);
var CtrlApp = function($scope){
$scope.pessoas = [
{nome:'jayson',cidade: 'goiania'},
{nome:'Issis',cidade: 'sao'},
{nome:'Cida',cidade: 'teresina'},
{nome:'Jose',cidade: 'acreuna'}
];
$scope.adicionar = function(){
$scope.pessoas.push({
nome: $scope.vName,
cidade: $scope.vCidade
});
$scope.vName = "";
$scope.vCidade = "";
}
$scope.remover = function(index){
$scope.pessoas.splice(index,1);
}
}
myApp.controller('CtrlApp', CtrlApp);
</script>
</html>