Angular Filter Nested JSON Hierarchical Treeview in Controller

Rate this post

Angular Filter Nested JSON Hierarchical Treeview in Controller

In this Post We Will Explain About is Angular Filter Nested JSON Hierarchical Treeview in Controller With Example and Demo.Welcome on infinityknow.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Angularjs Filter JSON hierarchy tree in controllerExample

In this post we will show you Best way to implement Filter JSON In Hierarchical Way Using AngularJS, hear for filtering – AngularJS displaying hierarchical datawith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Make a HTML file and define markup

[php]

Filter JSON In Nested Using AngularJS Example

.live_panel {
margin:auto;
width:800px;
}

//some code………

READ :  PHP str_replace() Function with Examples

</html
[/php]

Make a Body Part define markup

[php]

  • {{data.name}}
  • 0″>
    • Enter Programing text to filter data
      • {{data.name}}
        0″>

        • {{data.name}}
          0″>

          [/php]

          Make a js file and define scripting

          Create a Module
          [php]
          var liveApp = angular.module(‘liveApp’, []);
          [/php]

          Create a Simple Controller using AngularJS
          [php]
          function liveCtrl($scope) {
          $scope.postData = [ {
          “name” : “Java Script”,
          “second_chield” : [ {
          “name” : “Angularjs”,
          “second_chield” : []
          }, {
          “name” : “Vue js”,
          “second_chield” : []
          } ]
          }, {
          “name” : “Server Side”,
          “second_chield” : [ {
          “name” : “PHP”,
          “second_chield” : []
          }, {
          “name” : “Laravel”,
          “second_chield” : []
          } ]
          }, {
          “name” : “Google”,
          “second_chield” : [ {
          “name” : “Youtube”,
          “second_chield” : []
          }, {
          “name” : “Analytics”,
          “second_chield” : []
          } ]
          } ];
          $scope.all_programdata = [];

          $scope.$watch(‘query_str’, function() {
          if ($scope.query_str == null || $scope.query_str.length == 0) {
          $scope.display_filterdata = false;
          } else {
          $scope.all_programdata = [];
          var temp = angular.copy($scope.postData);
          $scope.convert_lower_str = $scope.query_str
          .toLowerCase();
          $scope.filterResources(temp);
          $scope.display_filterdata = true;
          $scope.all_programdata = temp;
          }
          });

          $scope.filterResources = function(program_list) {
          for (var i = 0; i 0) {
          $scope.filterResources(program_list[i].second_chield);
          if (program_list[i].second_chield.length == 0) {
          var name = program_list[i].name.toLowerCase();
          if (!(name.indexOf($scope.convert_lower_str) >= 0)) {
          program_list.splice(i, 1);
          i–;
          }
          }
          } else {
          var name = program_list[i].name.toLowerCase();
          if (!(name.indexOf($scope.convert_lower_str) >= 0)) {
          program_list.splice(i, 1);
          i–;
          }
          }
          }
          };

          READ :  vuejs dynamic components - Dynamically add-remove row using vuejs

          }
          [/php]

          Full Code : Filter JSON In Nested Using AngularJS Example

          [php]

          Filter JSON In Nested Using AngularJS Example

          .live_panel {
          margin:auto;
          width:800px;
          }

        • {{data.name}}
        • 0″>
          • Enter Programing text to filter data
            • {{data.name}}
              0″>

              • {{data.name}}
                0″>

                var liveApp = angular.module(‘liveApp’, []);

                function liveCtrl($scope) {
                $scope.postData = [ {
                “name” : “Java Script”,
                “second_chield” : [ {
                “name” : “Angularjs”,
                “second_chield” : []
                }, {
                “name” : “Vue js”,
                “second_chield” : []
                } ]
                }, {
                “name” : “Server Side”,
                “second_chield” : [ {
                “name” : “PHP”,
                “second_chield” : []
                }, {
                “name” : “Laravel”,
                “second_chield” : []
                } ]
                }, {
                “name” : “Google”,
                “second_chield” : [ {
                “name” : “Youtube”,
                “second_chield” : []
                }, {
                “name” : “Analytics”,
                “second_chield” : []
                } ]
                } ];
                $scope.all_programdata = [];

                $scope.$watch(‘query_str’, function() {
                if ($scope.query_str == null || $scope.query_str.length == 0) {
                $scope.display_filterdata = false;
                } else {
                $scope.all_programdata = [];
                var temp = angular.copy($scope.postData);
                $scope.convert_lower_str = $scope.query_str
                .toLowerCase();
                $scope.filterResources(temp);
                $scope.display_filterdata = true;
                $scope.all_programdata = temp;
                }
                });

                READ :  Get the Http headers from current request in PHP Laravel 6

                $scope.filterResources = function(program_list) {
                for (var i = 0; i 0) {
                $scope.filterResources(program_list[i].second_chield);
                if (program_list[i].second_chield.length == 0) {
                var name = program_list[i].name.toLowerCase();
                if (!(name.indexOf($scope.convert_lower_str) >= 0)) {
                program_list.splice(i, 1);
                i–;
                }
                }
                } else {
                var name = program_list[i].name.toLowerCase();
                if (!(name.indexOf($scope.convert_lower_str) >= 0)) {
                program_list.splice(i, 1);
                i–;
                }
                }
                }
                };

                }

                [/php]

                Example

                I hope you have Got What is Angularjs Filter Nested JSON Hierarchical Treeview in Controller And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.

                Leave a Reply

                Your email address will not be published.