displaying json data via modal or table with ng-click

Issue

need help while displaying json conect. When i press a username i need to display that particular user details in a modal or a table . any suggestions on how to do that using onclick ?

         var mainApp= angular.module("mainApp", []);

    mainApp.controller('TableFilterController', function($scope) {
   $scope.clickMe = function(p) {
        $scope.selected = p;
    }

    $scope.isSelected = function(p) {
        return $scope.selected === p;
    }
      $scope.details = [
        {
          name : 'Mercury',
          age : 0.4,
          mass : 0.055,
          descp : 'it is the hottest planet',
        },

https://plnkr.co/edit/FluJQRlTkdsNfv1NLDhW?p=preview

Solution

You can popup a dilaog box using a $modal of bootstrap,

 $modal.open({
      templateUrl: 'myModalContent.html',
      backdrop: true,
      windowClass: 'modal',
      controller: function($scope, $modalInstance, $log) {
        $scope.selected = p;
        $scope.submit = function() {
          $log.log('Submiting user info.');
          $log.log($scope.selected);
          $modalInstance.dismiss('cancel');
        }
        $scope.cancel = function() {
          $modalInstance.dismiss('cancel');
        };
      },
      resolve: {
        user: function() {
          return $scope.selected;
        }
      }
    });

DEMO WITH PLUNKER

Answered By – Sajeetharan

Answer Checked By – Willingham (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.