How will you convert a string into a percentage?



How will you convert a string into a percentage?..

Answer / Mohit Chandra Joshi

You can convert a string representing a number followed by '%' to a percentage in AngularJS using the following: var percent = parseFloat(string) / 100; For example: var str = '50%'; var percent = parseFloat(str) / 100; // percent now contains 0.5

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More AngularJS Interview Questions

Explain directives ng-if, ng-switch and ng-repeat?

1 Answers  


What is router-link directive in angular?

1 Answers  


How to disable right click event in angularjs?

1 Answers  


How to viewing the angular 4 apps in a browser using ionic 3 cli?

1 Answers  


Should you use angular?

1 Answers  


List down the popular angularjs ide plugins/extensions for web development?

1 Answers  


What is RouterOutlet?

1 Answers  


What is change detection strategy in angular?

1 Answers  


Explain the role of $routeprovider in angularjs?

1 Answers  


Why would you use renderer methods instead of using native element methods?

1 Answers  


What is ngdobootstrap?

1 Answers  


What is $timeout in angularjs?

1 Answers  


Categories