Muhad
Muhad

Reputation: 283

How to create form in Angular JS?

There is block HTML with article:

<div class="block">
   <span ng-click="edit()">Click</span>
   <div class="title">How to</div>
   <div class="text">Text</div>
</div>

When I call edit function ng-click="edit()" I call AJAX that returns data:

title
text

These data I set in $scope:

$scope.title = title;
$scope.text = text;

How I can create form with input, textarea instead HTML in .block? I neeed to switch on edit mode and display form for editing.

Upvotes: 0

Views: 66

Answers (1)

ergonaut
ergonaut

Reputation: 7057

You are essentially asking how to do a form. I would try going through some examples from the documentation eg. https://docs.angularjs.org/api/ng/directive/form

paying key attention to the ng-model="" tags to bind your data fields. Then the scope variables should automatically update your form.

Upvotes: 1

Related Questions