Created
June 1, 2014 21:59
-
-
Save renatocantarino/b42d79af450836b98858 to your computer and use it in GitHub Desktop.
Module.
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
<html ng-app='AngularIntro'> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script> | |
</head> | |
<body ng-controller='SimpleController'> | |
<input type='text' ng-model='name'> | |
<input type='button' value='Adicionar' ng-click='addName()'> | |
<table> | |
<tr ng-repeat="pessoa in Vizinhos"> | |
<td>{{pessoa}}</td> | |
</tr> | |
</table> | |
<script> | |
//Inicialização do módulo | |
var module = angular.module('AngularIntro', []); | |
//Adição do Controller ao módulo | |
module.controller('SimpleController', function($scope){ | |
$scope.Vizinhos = ['Jose', 'Mr M', 'Sbrubles', 'Maria']; | |
$scope.addName = function(){ | |
var name = $scope.name; | |
if($scope.Vizinhos.indexOf(name) == -1) | |
$scope.Vizinhos.push(name); | |
$scope.name = ''; | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment