React JS Training Course Online
- 20k Enrolled Learners
- Weekend
- Live Class
Hi, let’s learn about an interesting directive provided in AngularJS, i.e. ng-change directive, the name itself partially gives away the work that it performs. Programmers usually get confused between on-change and ng-change events, let’s clear out everything today in this blog. The topics we will take up today will be:
Before proceeding with the blog, we will first have a quick look at what Directives are in AngularJS.
AngularJS directives are simply extended HTML attributes with a prefix ‘ng-‘. AngularJS provides a set of built-in directives which offer various functionalities to our applications.
AngularJS also lets us define our own directives.
Ng-change is a directive in AngularJS which is meant for performing operations when a component value or event is changed. In other words, ng-change directive tells AngularJS what to do when the value of an HTML element changes.
An ng-model directive is required by the ng-change directive.
Note, this directive requires ngModel to be present.
<element ng-change=“expression”></element>
Find out our Flutter Course in Top Cities
India | Other Countries |
Flutter Training in Chennai | Flutter Course in Australia |
Flutter Course in Bangalore | Flutter Course in Canada |
Flutter Training in Hyderabad | Flutter Course in London |
expression: It specifies an expression that is executed when value of an element changes.
<!DOCTYPE html> <html> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <body ng-app="App1"> <div ng-controller="Cng1"> <p>Please type in the input field:</p> <input type="text" ng-change="myFunc()" ng-model="Val" /> <p>The input field has changed {{count}} times.</p> </div> <script> angular.module('App1', []) .controller('cng1l', ['$scope', function($scope) { $scope.count = 0; $scope.myFunc = function() { $scope.count++; }; }]); </script> </body> </html>
Output (After 3 changes)
Please type in the input field:
The input field has changed 3 times.
I hope, by now you might have got a clear understanding of the ng-change directive, try to use it in your programs and see how much you have learned. Thanks for reading. I would recommend you to go through this Angular Tutorial Edureka video playlist to watch videos and learn how to work with the Angular applications.
Learn the latest trends and techniques in UI/UX design through UX Design Course.
A Flutter Certification Course will help you master the skills necessary to create outstanding mobile apps that users love.
Now that you know the Angular Directive, check out the Angular Course by Edureka, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe. Angular is a JavaScript framework which is used to create scalable, enterprise, and performance client-side web applications. With Angular framework adoption being high, performance management of the application is community driven indirectly driving better job opportunities. The Angular Certification Training aims at covering all these new concepts around Enterprise Application Development.
Course Name | Date | Details |
---|---|---|
Angular Certification Training Course Online | Class Starts on 21st September,2024 21st September SAT&SUN (Weekend Batch) | View Details |
edureka.co