<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Reverse a String using AngularJS</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<style type="text/css">
#main
{
width:960px;
margin:50px auto;
font-family:raleway;
}
#form_layout
{
width:300px;
float: left;
border-radius: 10px;
font-family:raleway;
border: 2px solid #ccc;
padding: 10px 40px 25px;
margin-top: -2px;
}
</style>
<script type="text/javascript">
var app = angular.module("MyApp", []);
app.filter("reverse", function() {
return function(input) {
input = input + " ";
var ch1 =0;
var ch2 =0 ;
var ans= "";
for (var i=0; i<input.length-1; i++)
{
ch1=input.charAt(i); // Extracting the first character
ch2=input.charAt(i+1); // Extracting the next character
if(ch1!=ch2)
{
ans = ans + ch1;
}
}
return ans;
};
});
</script>
</head>
<body ng-app="MyApp">
<div id="loginModal" class="modal show" tabindex="-1" role="dialog" aria-hidden="true">
<br> <br><br> <br><br> <br><br> <br>
<div class="modal-dialog">
<div class="modal-content">
<h3 align="center"> Recursive Removal in a String Using AngularJS</h3>
<hr color =" black">
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-xs-4"> Enter the String : </label>
<div class="col-xs-6">
<input type="text" class="form-control" id="text1" ng-model="text" placeholder="Jaaavvvvvvvvaaaaaaaaaaa"/>
</div>
</div>
<br>
<div class="form-group">
<div class="col-xs-offset-3 col-xs-4">
<input type="reset" class="btn btn-default" value="Reset" onClick="history.go(0)" >
</div>
</div>
<br>
<div class="form-group">
<label class="control-label col-xs-2"> </label>
<div class="col-xs-6">
<b>Reversed String is : <span style="color:red"> {{ text | reverse }} </span></b>
<br>
</div>
</div>
</div>
</form>
</div>
</div >
</div>
</body>
</html>
Output:
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Reverse a String using AngularJS</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<style type="text/css">
#main
{
width:960px;
margin:50px auto;
font-family:raleway;
}
#form_layout
{
width:300px;
float: left;
border-radius: 10px;
font-family:raleway;
border: 2px solid #ccc;
padding: 10px 40px 25px;
margin-top: -2px;
}
</style>
<script type="text/javascript">
var app = angular.module("MyApp", []);
app.filter("reverse", function() {
return function(input) {
input = input + " ";
var ch1 =0;
var ch2 =0 ;
var ans= "";
for (var i=0; i<input.length-1; i++)
{
ch1=input.charAt(i); // Extracting the first character
ch2=input.charAt(i+1); // Extracting the next character
if(ch1!=ch2)
{
ans = ans + ch1;
}
}
return ans;
};
});
</script>
</head>
<body ng-app="MyApp">
<div id="loginModal" class="modal show" tabindex="-1" role="dialog" aria-hidden="true">
<br> <br><br> <br><br> <br><br> <br>
<div class="modal-dialog">
<div class="modal-content">
<h3 align="center"> Recursive Removal in a String Using AngularJS</h3>
<hr color =" black">
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-xs-4"> Enter the String : </label>
<div class="col-xs-6">
<input type="text" class="form-control" id="text1" ng-model="text" placeholder="Jaaavvvvvvvvaaaaaaaaaaa"/>
</div>
</div>
<br>
<div class="form-group">
<div class="col-xs-offset-3 col-xs-4">
<input type="reset" class="btn btn-default" value="Reset" onClick="history.go(0)" >
</div>
</div>
<br>
<div class="form-group">
<label class="control-label col-xs-2"> </label>
<div class="col-xs-6">
<b>Reversed String is : <span style="color:red"> {{ text | reverse }} </span></b>
<br>
</div>
</div>
</div>
</form>
</div>
</div >
</div>
</body>
</html>
Output:
No comments:
Post a Comment