angular.isString: This function is used to check whether a reference is string or not. The function isString will return true if passed reference is string else it will return false. Here in this tutorial we are going to explain how you can use this function to determine a string in AngularJs. You can use our online editor to edit and run the code online.
angular.isString – Check if Reference is String | Example
Sytax for angular.isString is as below-
Syntax –
angular.isString Syntax
angular.isString(value); |
The above function checks whether the passed string(reference) is String or not and on the basis of that it returns true or false.
Arguments
- value : This is reference to check.
Returns
- boolean : Returns true if reference is String else it will return false.
Now let us create a simple example to understand the above function.
Example
AngularJs check string type: Check If String
<div ng-app="myApp"> <div ng-controller="myController"> <button ng-click="chackStr()">Check String</button> <br/> Result for a = {{result1}}<br/> Result for b = {{result2}} </div> </div> |
If you run the above example it will produce the output something like this –