AngularJS Simple Example
by Ben Clayton
HTML
<div ng-app ng-controller="LoginController">
<div>Hello {{ user.firstName }}</div>
<input ng-model="user.firstName"></input>
<input type="submit" ng-click="login()" value="Login"></input>
<div ng-repeat="login in logins">{{ login }}</div>
</div>
JavaScript
var clients=new Array;
clients.push(new block());
clients[0].firstname = "one";
clients[1].firstname = "two";
function LoginController($scope) {
$scope.user = {
firstName: "",
lastName: ""
};
$scope.logins = [];
$scope.login = function () {
$scope.logins.push($scope.user.firstName + " was logged in.");
};
}
function block(){
this.firstName = '';
this.lastName = '';
}