AngularJS supports .val() jQuery functionality. Here in below examples we can see how to read value of an element.

Using ng-model

ng-model is directive to hold input variable
<input ng-bind="val" value="default value"/>
<br/>
{{val}}
<script>
function myCtrl($scope) {
    $scope.val = 'my val var'; 
}
</script>
Try It Your Self

Steps to read input value using Angular Element:

  1. Get angular element of html element
  2. Use .val() method to read input value
var myEl = angular.element( document.querySelector( '#inputID' ) );
myEl.val();

Steps to set input value using Angular Element:

  1. Get angular element
  2. Use .val('value') method to set value
var myEl = angular.element( document.querySelector( '#inputID' ) );
myEl.val('my value');

9 comments:

  1. As a beginner this helps to learn AngularJS. Thanks for sharing this, Bookmarked

    Related Topic: http://www.credosystemz.com/training-in-chennai/best-angularjs-training-in-chennai/

    ReplyDelete
  2. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.


    Big Data Training in Bangalore

    ReplyDelete
  3. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
    datascience training in chennai

    ReplyDelete
  4. I simply wanted to thank you so much again. I am not sure the things that I might have gone through without the type of hints revealed by you regarding that situation.
    Best selenium training Institute in chennai

    ReplyDelete
  5. Thanks for sharing with us. This is very Great aticle , it gives more useful information.
    http://www.metaforumtechnologies.com/angularjs-training-in-chennai

    ReplyDelete

Blogroll

Follow this blog by Email

Popular Posts