Important Notice:

AngularJS

AngularJS

34 views 3 min read

 

AngularJS

 Introduction:-

AngularJS एक popular client-side JavaScript framework है। इसकी मदद से HTML web pages को ज्यादा dynamic, interactive और user-friendly बनाया जा सकता है। यह एक powerful framework है जो Single Page Applications (SPAs) बनाने के लिए सबसे ज्यादा use किया जाता है।

AngularJS लगभग सभी web browsers (जैसे Chrome, Firefox, Edge) और operating systems (Windows, Linux, macOS) पर काम करती है। इसके द्वारा dynamic web pages बनाए जा सकते हैं। साथ ही, इसका उपयोग mobile applicationweb applicationreal-time applicationform validation, और data binding वाली apps बनाने में भी किया जाता है।

AngularJS MVC (Model-View-Controller) pattern पर based है। यह HTML को directives (जैसे ng-app, ng-model, ng-repeat) नाम के special attributes देता है, जिससे HTML की power बढ़ जाती है। इसमें two-way data binding की सुविधा होती है, मतलब model और view के बीच data अपने आप sync होता रहता है।

Who created AngularJS?

AngularJS को Misko Hevery और Adam Abrons ने 2009 में banaya था। शुरुआत में इसे Brat Tech LLC ने develop किया था। बाद में Google company ने इस framework को officially maintain और support करना start कर दिया।

AngularJS का first version (1.0) year 2012 में release हुआ था। इसका last stable version 1.8.3 है, और इसका official support 31 December 2021 को खत्म हो चुका है। अब इसकी जगह नया Angular (version 2+) use किया जाता है।

जब Google ने AngularJS को पूरी तरह नया बनाकर launch किया, तो उसका नाम Angular 2 रखा गया।

इसके बाद आने वाले सभी versions:

  • Angular 2
  • Angular 4
  • Angular 5
  • Angular 10
  • Angular 17
  • Angular 19

को collectively Angular 2+ कहा जाता है।

AngularJS की मुख्य विशेषताएँ (Key Features)

  1. Two-way Data Binding – Model और view के बीच automatic sync होता है। बिना extra code likhe data update होता रहता है।

  2. Directives – ये special HTML attributes होते हैं जैसे ng-appng-modelng-repeatng-bindng-show, आदि।

  3. MVC Pattern – Logic (controller), data (model), और UI (view) ko alag rakhta है, जिससे code organized और maintainable रहता है।

  4. Templates – HTML के अंदर expressions {{ }} use होते हैं जो JavaScript जैसा काम करते हैं।

Simple Example

html
<!DOCTYPE html>
<html ng-app="myApp"> <!-- ng-app AngularJS Application को शुरू करता है -->
<head>
    <!-- AngularJS Library को Google CDN से Load किया गया है -->
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
</head>
<!-- ng-controller Controller को Body के साथ जोड़ता है -->
<body ng-controller="myCtrl">
<!--Input Box
        ng-model="username" एक Model Variable बनाता है।
        User जो भी टाइप करेगा, वह username में Store होगा।    -->
    <input type="text" ng-model="username" placeholder="Enter Your Name">
 <!--
        {{ username }} Expression Binding है।
        यह username की Value को Screen पर दिखाता है।
        Input में Value बदलते ही Output Automatically Update हो जाता है।    -->
    <h1>नमस्ते, {{ username }}!</h1>
<script>
        // AngularJS Module बनाना
        // "myApp" Application का नाम है
        var app = angular.module("myApp", []);

        // Controller बनाना
        // Controller Application का Logic संभालता है
        app.controller("myCtrl", function($scope) {

            // Default Value Set करना
            // Page Load होने पर username की Value "Guest" होगी
            $scope.username = "Guest";
 });
    </script>

</body>
</html>

  AngularJS के फायदे (Advantages)
  • HTML को dynamic बनाना बहुत easy हो जाता है।

  • Reusable components (directives) बना सकते हैं।

  • Testing करना easy है क्योंकि dependency injection होता है।

  • Google का support रहा है (हालाँकि अब पुराना हो चुका है)।

AngularJS के नुकसान (Disadvantages)
  • Performance slow हो सकती है जब large applications बनाएँ।

  • Mobile support utna accha नहीं है।

  • Official support खत्म हो चुका है, इसलिए नए projects में Angular (2+), React, या Vue.js use करना better है।

 

Related Notes