AngularJs Substring

AngularJs Substring: JavaScript substring Method is used to extract characters of string between two specified positions ie start and end. Here in this tutorial we are going to explain how you can use JavaScript substring() method to extract character from string. You can also use our online editor to edit and run the code online.

AngularJs Substring JavaScript Example

Let us create an example to understand how to use JavaScript substring function to extract the characters in AngularJs-

AngularJs Substring Method Example:

<!DOCTYPE html>
<html lang="en">
 <script src="//"></script>
var myApp = angular.module("myApp", []);
 myApp.controller("myController", function($scope) {
 $scope.exampleString = "Hello World!";
 $scope.result = '';
 $scope.substringExample = function(){
  $scope.result = $scope.exampleString.substring(1,4);
<div ng-app="myApp">  
<div ng-controller="myController"> 
<button type="button" ng-click="substringExample()">Click Me</button>
<p>Result = {{result}}</p>

Try it »

In the above example we have created an example which will extract characters from the string.
If you run the above example it will produce output something like this –

AngularJs Substring JavaScript Example


Add Comment

📖 Read More