জয়েন লগইন

অ্যাঙ্গুলারজেএস destroy

🌈অ্যাঙ্গুলারজেএস destroy কি?

📋অ্যাঙ্গুলারজেএস destroy হলো স্কোপ ধ্বংস করার পদ্ধতি।

⚒️অ্যাঙ্গুলারজেএস destroy স্কোপ ধ্বংস করতে ব্যবহৃত হয়।

অ্যাঙ্গুলারজেএস destroy স্কোপ ধ্বংস করার উদাহরণ।

angularjs
<!DOCTYPE html>
<html ng-app="app">
<body>

  <div ng-controller="app">
    <p>{{message}}</p>
    <button ng-click="remove()"></button>
  </div>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.3/angular.min.js"></script>
  <script>
    angular.module("app", [])
      .controller("app", function($scope) {
        $scope.message = "স্কোপ সক্রিয় রয়েছে";

        $scope.$on("$destroy", function() {
          console.log("Scope destroyed");
        });

        $scope.remove = function() {
          $scope.$destroy();
        };
      });
  </script>

</body>
</html>