Category Archives: AngularJs blog

AngularJs Round to 2 decimal places


AngularJs Round to 2 decimal places: We often need to round decimal numbers upto two places. We can use JavaScript toFixed() method to round the decimal number upto to the two places. Here in this tutorial we are going to explain how you can use this method to round the decimal numbers. You can also use our online editor to edit and run the code online.


AngularJs Round to 2 decimal places Example

You can use JavaScript toFixed() method to round the decimal numbers upto two places simply as below-

AngularJs Round to 2 decimal places Example:

 
 

  

Result = {{result}}

Try it »

If you run the above example it will produce the output something like this –

AngularJs Round to 2 decimal places

AngularJs Trim String


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


AngularJs Trim String Example

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

AngularJs Trim String Example:

 
 

  

Result = {{result}}

Try it »

If you run the above example it will produce the output something like this –

AngularJs Trim String Example

AngularJs Check String StartsWith


AngularJs Check String StartsWith: We can use JavaScript startsWith() method to check whether a string starts with certain characters. Here in this tutorial we are going to explain how you can use JavaScript startsWith() function to check whether the string starts with certain characters in AngularJs.


AngularJs Check String StartsWith Example

JavaScript startsWith() method checks whether a string starts with certain characters. This method returns true if the character match is found at the starting of the string else it will return false. Let us create an example to understand how we can use JavaScript startswith method in AngularJs.

AngularJs Check String StartsWith Example:

 
 

  

Result = {{result}}

Try it »

If you run the above example it will produce output something like this –

AngularJs Check String StartsWith Example

AngularJs String Search


AngularJs String Search: Sometimes we need to search a value in specified String In AngularJs, we can use JavaScript search() method to search the value in Specified String. Here in this tutorial we are going to explain how you can use JavaScript Search function to search the specified value in AngularJs String.


AngularJs String Search Example

JavaScript search() method searches a value in string and returns the position of the match. The search value can be string or regular expression. If the match is not found it will return -1. Let us create an example to understand how we can use JavaScript Search method in AngularJs.

AngularJs String Search Example:

 
 

  

Result = {{result}}

Try it »

If you run the above example it will produce output something like this –

AngularJs String Search Example

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:

 
 

  

Result = {{result}}

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

AngularJs String SubStr


AngularJs String SubStr: JavaScript SubStr Method is used to extract parts of string between two specified positions ie. start and end and it returns the string between the specified location. Here in this tutorial we are going to explain how you can use JavaScript substr() method to extract parts of a string. You can also use our online editor to edit and run the code online.


AngularJs String SubStr JavaScript Example

Let us create an example to understand how to use JavaScript substr function in AngularJs-

AngularJs String SubStr Method Example:

 
 

  

Result = {{result}}

Try it »

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

AngularJs String SubStr Example

AngularJs String Slice JavaScript


AngularJs String Slice: Slice Method is used to extract parts of string. We can use JavaScript slice() method to extract parts of string. Here in this tutorial we are going to explain how you can use JavaScript slice() method to extract parts of a string. You can also use our online editor to edit and run the code online.


AngularJs String Slice JavaScript Example

We can use JavaScript Slice() method to extract a part of string. Let us create an example to understand this in AngularJs-

AngularJs String Slice Method Example:

 
 

  

Result = {{result}}

Try it »

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

AngularJs String Slice JavaScript Example

Angular2 npm start not working Ubantu


Angular2 npm start not working Ubantu(Linux): We sometimes face issue when working with Angular2 npm command in Ubantu. This happens if you apt-get install nodejs package from Ubuntu(linux). This issue may be due to version problem. Here is a quick fix for it.


Angular2 npm start not working Ubantu Fix

You can fix the following issue by the command below –

Errors/Warnings That occurred in my case :

1. concurrent “npm run tsc:w” “npm run lite”

/usr/bin/env: node: No such file or directory

2. This failure might be due to the use of legacy binary “node”

I run this and it fixed for me –

AngularJs 2 npm start not Working Example:

sudo ln -s /usr/bin/nodejs /usr/bin/node

AngularJs ng-include based on Condition


AngularJs ng-include based on Condition: Sometimes we need to include another html page(template) based on some condition. You can use ng-if to include another page on the based of some condition. Here in this tutorial we are going to explain how you can Add condition while including another page. You can also use our online editor to edit and run the code online.


AngularJs ng-include based on Condition Example

If you want to include another page using ng-include and you want to include that template only when some condition is met. Let us create an example to add if condition to load another Html page-

AngularJs ng-include Example Based on Condition:

In the above example the template will be included only when ng-if condition is satisfied.