<!DOCTYPE html> <html lang="en" ng-app="myModule"> <head> <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/> <link rel="stylesheet" type="text/css" href="css/bootstrap.css" /> </head> <body ng-controller="myController"> <nav class="navbar navbar-default"> <div class="containet-fluid"> </div> </nav> <div class="col-md-6 well"> <hr style="border-top:1px dotted #ccc;"/> <div class="col-md-4"> <form> <div class="form-group"> <input type="text" class="form-control" ng-model="newUser.firstname"/> </div> <div class="form-group"> <input type="text" class="form-control" ng-model="newUser.lastname"/> </div> <div class="form-group"> <input type="text" class="form-control" ng-model="newUser.address"/> </div> </form> </div> <div class="col-md-8"> <table class="table table-bordered"> <thead class="alert-info"> <tr> </tr> </thead> <tbody> <tr ng-repeat="user in users"> </tr> </tbody> </table> </div> </div> </body> </html>
var app = angular.module("myModule", []) .controller("myController", function($scope){ $scope.newUser = {}; $scope.users = [ {firstname: "John", lastname: "Smith", address: "New York"} ]; $scope.saveUser = function(){ $scope.users.push($scope.newUser); $scope.newUser = {}; }; });