Assignment 9
Assignment 9
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Assignment-9</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="Assignment9.js"></script>
</head>
<body>
<h3><b>Registraion Form</b></h3>
</div>
<div align="right">
</div>
<input type = "text" id = "name" class = "form-control" placeholder = "Enter Name " ng-model =
"newcontact.name">
</div>
</div>
</div>
</div>
</div>
<br>
</form>
<div><h4><b>Registered Users</b></h4>
<thead>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Age</th>
<th ng-if="!ifSearchUser">Action</th>
</tr>
</thead>
<tbody>
<td ng-if="!ifSearchUser">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
Angular JS
ar myApp = angular.module("myApp", []); myApp.service("ContactService"
, function(){
var uid = 1;
var contacts = [{
'id' : 0,
'email' : '[email protected]',
'password': 'SumedhaZ',
'phone' : '123456789',
'age' : '19'}];
// Save Service for sving new contact and saving existing edited contact.
this.save = function(contact)
if(contact.id == null)
contact.id = uid++;
contacts.push(contact);
else
for(var i in contacts)
if(contacts[i].id == contact.id)
contacts[i] = contact;
};
this.get = function(id)
{
for(var i in contacts )
return contacts[i];
};
//Delete a contact
this.delete = function(id)
for(var i in contacts)
if(contacts[i].id == id)
contacts.splice(i,1);
};
this.list = function()
return contacts;
};
});
console.clear();
$scope.ifSearchUser = false;
$scope.contacts = ContactService.list();
$scope.saveContact = function()
console.log($scope.newcontact); if($scope.newcontact ==
return;
ContactService.save($scope.newcontact);
$scope.newcontact = {};
};
$scope.delete = function(id)
ContactService.delete(id);
$scope.newcontact = {};
};
$scope.edit = function(id)
$scope.newcontact = angular.copy(ContactService.get(id));
};
Users"){
$scope.ifSearchUser=true;
$scope.title = "Back";
else
$scope.ifSearchUser = false;
};
});
Output