📌 Built-in Directives in AngularJS
AngularJS comes with powerful built-in directives to extend HTML functionality.
AngularJS directives are special attributes or elements that tell the framework how to behave. They add powerful logic directly into your HTML markup.
🔹 Commonly Used Built-in Directives
- ng-model: Binds input fields to model data.
-
ng-bind: Binds expression to HTML, similar to
{{ }}, but safer against flickering. - ng-init: Initializes variables in the current scope.
- ng-repeat: Iterates over collections (arrays or objects).
- ng-if: Conditionally includes an element in the DOM.
- ng-show / ng-hide: Shows or hides an element based on a boolean condition.
💡 Example: ng-repeat and ng-if
<div ng-init="users=['Alice', 'Bob', 'Charlie']">
<ul>
<li ng-repeat="user in users">
{{ user }}
</li>
</ul>
<p ng-if="users.length === 0">No users found.</p>
</div>
🧪 Example: ng-model and ng-show
<input type="checkbox" ng-model="showInfo"> Show Info
<div ng-show="showInfo">
<p>You checked the box!</p>
</div>


