Ng-Submit-1

 

Ng-Submit-1

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> </head> <body ng-app="app"> <div ng-controller="ExampleController"> <div class="container"> <b>Name List</b> <ul class="unstyled"> <li ng-repeat="todo in arrs"> <span class="done-{{todo.done}}">{{todo.text}}</span> </li> </ul> <form ng-submit="addRecords()"> <input type="text" ng-model="name" class="form-control" placeholder="add name here"><br /> <input class="btn btn-primary" type="submit" value="add"> </form> </div> </div> <script> var app = angular.module("app", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.arrs = [{ text: "John", done: false }, { text: "Kim", done: false }]; $scope.addRecords = function () { $scope.arrs.push({ text: $scope.name, done: false }); $scope.name = ""; } }]); </script> </body> </html>
Output