AngularJs Check String StartsWith – Angular Check String

AngularJs Check String StartsWith – Angular Check String

AngularJs Check String: generally we’d like to look a worth in specified String In AngularJs, we will use JavaScript search() technique to look the worth in specified String. Here during this tutorial we have a tendency to square measure reaching to justify however you’ll be able to use JavaScript Search operate to look the desired worth in AngularJs String.

AngularJs Check String StartsWith Example

JavaScript search() technique searches a worth in string and returns the position of the match. The search worth will be string or regular expression. If the match isn’t found it’ll return -1. allow us to produce associate degree example to grasp however we will use JavaScript Search technique in AngularJs.

HTML OF Angular Check String StartsWith

<div ng-app="myAppStartsWith">  
	<div ng-controller="myControllerStartsWith"> 
		<button type="button" ng-click="startswithDemo()">Click Hear for AngularJs Check String StartsWith</button>
		<p>Result = {{result}}</p>
	</div> 
</div>

script Of Angular Check String StartsWith

var myAppStartsWith = angular.module("myAppStartsWith", []);
myAppStartsWith.controller("myControllerStartsWith", function($scope) {
$scope.exampleString = "This is Hello World Example at onlinecode!";
$scope.result = '';
$scope.startswithDemo = function(){
$scope.result = $scope.exampleString.startsWith("Hello");
}
});

Angular String Search Example

<!DOCTYPE html>
<html lang="en">
<head>
	<title>Angular Check String StartsWith - onlinecode</title>
	<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script>
	<script>
		var myAppStartsWith = angular.module("myAppStartsWith", []);
		myAppStartsWith.controller("myControllerStartsWith", function($scope) {
			$scope.exampleString = "This is Hello World Example at onlinecode!";
			$scope.result = '';
			$scope.startswithDemo = function(){
				$scope.result = $scope.exampleString.startsWith("Hello");
			}
		});
	</script>
</head>
<body>  
	<div ng-app="myAppStartsWith">  
		<div ng-controller="myControllerStartsWith"> 
			<button type="button" ng-click="startswithDemo()">Click Hear for AngularJs Check String StartsWith</button>
			<p>Result = {{result}}</p>
		</div> 
	</div>
</body>  
</html>

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 *

42  +    =  48

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