0

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>

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.