Advertisement
Guest User

Untitled

a guest
Sep 29th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var app = angular.module('station', ['ui.bootstrap']);
  2. app.controller('ModalDemoCtrl', function ($scope, $modal, $log) {
  3.  
  4.  
  5.   $scope.items = ['item1', 'item2', 'item3'];
  6.   $scope.friends = [];
  7.  
  8.   $scope.addFriend = function(){
  9.         FB.api(
  10.            "/me/friends?fields=id,name,picture",
  11.            function (response) {
  12.              if (response && !response.error) {
  13.                  console.log(response.data.length);
  14.                  response.data.forEach(function(friend) {
  15.                     //console.log(friend);
  16.                     $scope.friends.push(friend );
  17.                 });
  18.                 $scope.$apply();
  19.                 console.log($scope.friends);
  20.              }
  21.            }
  22.        );
  23.    };
  24.  
  25.  
  26.   $scope.open = function (size) {
  27.  
  28.     var modalInstance = $modal.open({
  29.       templateUrl: 'myModalContent.html',
  30.       controller: 'ModalInstanceCtrl',
  31.       size: size,
  32.       resolve: {
  33.         items: function () {
  34.           return $scope.friends;
  35.         }
  36.       }
  37.     });
  38.  
  39.     modalInstance.result.then(function (selectedItem) {
  40.       $scope.selected = selectedItem;
  41.     }, function () {
  42.       $log.info('Modal dismissed at: ' + new Date());
  43.     });
  44.   };
  45. });
  46.  
  47. // Please note that $modalInstance represents a modal window (instance) dependency.
  48. // It is not the same as the $modal service used above.
  49.  
  50. app.controller('ModalInstanceCtrl', function ($scope, $modalInstance, items) {
  51.  
  52.   $scope.items = items;
  53.   $scope.selected = {
  54.     item: $scope.items[0]
  55.   };
  56.  
  57.   $scope.ok = function () {
  58.     $modalInstance.close($scope.selected.item);
  59.   };
  60.  
  61.   $scope.cancel = function () {
  62.     $modalInstance.dismiss('cancel');
  63.   };
  64. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement