Home How to Make Loop in Angular JS
Reply: 1

How to Make Loop in Angular JS

Fel
1#
Fel Published in 2018-02-14 02:57:50Z

I am new to angular Js How can I loop same ng-model?

I get that example on w3schools

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>

<div data-ng-app="" data-ng-init="price=5">

<h2>Cost Calculator</h2>


Price: <input type="number" ng-model="price">
        <input type="number" ng-model="price">

<p><b>Total in dollar:</b> {{price+price}}</p>

</div>

</body>
</html>
Manoj Bhardwaj
2#
Manoj Bhardwaj Reply to 2018-02-14 03:55:07Z

Use ngRepeat to Make Loop in Angular JS

   $scope.modelsdata = [{name:'Sam'},{name:'Harry'},{name:'Sally'}] in javascript 

Or you can use ng-init in html if you dont' want to use $scope.modelsdata

<div ng-repeat="model in modelsdata ">
    Value: {{model.name}}
    <input ng-model="model.name">                         
</div>
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.486763 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO