Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

I'm currently learning AngularJS and am having difficulty understanding the difference between ng-bind and ng-model.

Can anyone tell me how they differ and when one should be used over the other?

1 Answer

0 votes
by (106k points)

The difference between ng-model and ng-bind is as follows:-

  • The ng-bind has one-way data binding ($scope --> view). It has a shortcut {{ val }} it displays the scope value $scope.val inserted into html where val is a variable name.

  • Where as ng-model is intended to be put inside of form elements and has two-way data binding ($scope --> view and view --> $scope) An example regarding that is as follows:-  <input ng-model="val"/>.

Related questions

0 votes
1 answer
+2 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...