AngularJs String Trim with example – AngularJs Trim String

AngularJs String Trim with example – AngularJs Trim String

AngularJs String Trim : we can use JavaScript trim() method to remove spaces from both end. Here in this post we are going to explain and example for how you can use this function to Angular String Trim with example. we can also use our online example to edit and run the code online and demo.

Angular String Trim Example

JavaScript trim() function spaces removes from both end of the string, we can also use the same in AngularJs to remove blank spaces from String. Here is an example to remove the spaces from the string in AngularJs

AngularJs String Trim JS :

var myAppTrim = angular.module("myAppTrim", []);
	myAppTrim.controller("myControllerTrim", function($scope) {
		$scope.demoTrimString = " This Is AngularJs String Trim Example!! ";
		$scope.resultTrim = '';
		$scope.trimDemo = function(){
			$scope.resultTrim = $scope.demoTrimString.trim();
	}
});

Angular String Trim HTML :

<div ng-app="myAppTrim">  
	<div ng-controller="myControllerTrim"> 
		<button type="button" ng-click="trimDemo()">Click Hear For Trim</button>
		<p>Result = {{resultTrim}}</p>
	</div> 
</div>

AngularJs String Trim Example:

<!DOCTYPE html>
<html lang="en">
<head>
	<title>Angular String Trim with example - onlinecode</title>
	<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script>
	<script>
		var myAppTrim = angular.module("myAppTrim", []);
			myAppTrim.controller("myControllerTrim", function($scope) {
				$scope.demoTrimString = " This Is AngularJs String Trim Example!! ";
				$scope.resultTrim = '';
				$scope.trimDemo = function(){
					$scope.resultTrim = $scope.demoTrimString.trim();
			}
		});
	</script>
</head>
<body>  
	<div ng-app="myAppTrim">  
		<div ng-controller="myControllerTrim"> 
			<button type="button" ng-click="trimDemo()">Click Hear For Trim</button>
			<p>Result = {{resultTrim}}</p>
		</div> 
	</div>
</body>  
</html>

If you have got any suggestions or doubts for Angular String Trim please comment below and that we strive can response to each one in all you as early as attainable.

You also like AngularJs Pass Data to $http.get request AND AngularJs Call Function on Page Load with example

Leave a Comment

Your email address will not be published. Required fields are marked *

8  +  1  =  

We accept paid advance and paid guest Posting on our Site : Contact US