AngularJS में HTML DOM तत्वों के गुणों के लिए बाध्यकारी application डेटा के निर्देश हैं डोम document ऑब्जेक्ट मॉडल के लिए स्थिर है angularJS directives को HTML DOM elements की विशेषताओं के लिए आवेदन डेटा को बाइंड करने के लिए उपयोग में लाया जाता है.
AngularJS में, सभी निर्देशों का उपयोग HTML डोम तत्वों के गुणों में आवेदन डेटा को बाँधने के लिए किया जाता है Angularjs में 4 प्रकार के directive का उपयोग application डेटा को बाँधने के लिए किया जाता है -
ng-disabled directive
ng-show directive
ng-click directive
ng-hide directive
यह directive angularJS application डेटा को एचटीएमएल elements के disabled विशेषता में बांधने के लिए यूज़ होती है.
इस directive का उपयोग angularJS में एक HTML तत्व को दिखाने या छुपाने में किया जाता है.
यह directive एक angularJS क्लिक ईवेंट का प्रतिनिधित्व करता है और कुल क्लिक को HTML तत्व मानता है.
यह directive एक HTML तत्व को छुपाता है या फिर दिखाता है.
<!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <body> <div ng-app="" ng-init="mySwitch=true"> <p> <button ng-disabled="mySwitch">Click Me!</button> </p> <p> <input type="checkbox" ng-model="mySwitch"/>Button </p> <p> {{ mySwitch }} </p> </div> </body> </html>
Button
{{ mySwitch }}