Advertisement
Ranga14

AngularJS Contact Data List

Mar 17th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var appContact = angular.module('appContact', ['ngAnimate']);
  2. // var appToggle = angular.module('appToggle', ['ngAnimate']);
  3.  
  4. appContact.controller('controllerContact', function($scope, $http) {
  5.  
  6.     // Init list
  7.     getDataRows();
  8.  
  9.     // Show Contact Data
  10.     $scope.animate = false;
  11.     $scope.open = function(contactID) {
  12.         if ( $scope.animate = true ) {
  13.             $scope.animate = $scope.animate;
  14.         } else {
  15.             $scope.animate = !$scope.animate;
  16.         }
  17.        
  18.         console.log('working inside scope.' + contactID);
  19.        
  20.         getData(contactID);
  21.     }
  22.  
  23.     // Get all the data.
  24.     function getDataRows(){
  25.         $http.post('./objects/contacts.php').success(function(data){
  26.             $scope.contactSubs = data;
  27.         }).error(function(data, status) {
  28.             console.error('Repos error', status, data);
  29.         });
  30.     }
  31.  
  32.     // Get only one dataset
  33.     function getData(contactID){
  34.         $http.post('./objects/contacts-view.php', {id: contactID}).success(function(data){
  35.             $scope.contactData = data;
  36.             console.log('working inside scope.' + contactID);
  37.         }).error(function(data, status) {
  38.             console.error('Repos error', status, data);
  39.         });
  40.     }
  41.  
  42. });
  43.  
  44. angular.module('appControl', ['appContact']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement