AngularJS – isString() method

The isString() method in AngularJS basically checks if a reference is a string value or not. This method will return True if the reference passed inside the function is a string, else it will return False.

Syntax

angular.isString(value)

Example − Check if the reference is a String or not

Create a file "isString.html" in your Angular project directory and copy-paste the following code snippet.


   
      angular.isString()

      
   

   
      

         Welcome to Tutorials Point      

     

AngularJS | angular.isString()

     
         Name: {{name}}          

         {{isString}}          

         Name: {{name2}}          

         {{isString1}}          

         Name: {{name3}}          

         {{isString2}}      
           

Output

To run the above code, just go to your file and run it as a normal HTML file. You will see the following output on the browser window.

Observe that name and name2 are strings, whereas name3 is a key-value pair in the given code, which is why we got the output "$scope.name2 is not a String."

Updated on: 2021-10-08T10:55:57+05:30

360 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements