Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = angular.module('station', ['ui.bootstrap']);
- app.controller('ModalDemoCtrl', function ($scope, $modal, $log) {
- $scope.items = ['item1', 'item2', 'item3'];
- $scope.friends = [];
- $scope.addFriend = function(){
- FB.api(
- "/me/friends?fields=id,name,picture",
- function (response) {
- if (response && !response.error) {
- console.log(response.data.length);
- response.data.forEach(function(friend) {
- //console.log(friend);
- $scope.friends.push(friend );
- });
- $scope.$apply();
- console.log($scope.friends);
- }
- }
- );
- };
- $scope.open = function (size) {
- var modalInstance = $modal.open({
- templateUrl: 'myModalContent.html',
- controller: 'ModalInstanceCtrl',
- size: size,
- resolve: {
- items: function () {
- return $scope.friends;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- $scope.selected = selectedItem;
- }, function () {
- $log.info('Modal dismissed at: ' + new Date());
- });
- };
- });
- // Please note that $modalInstance represents a modal window (instance) dependency.
- // It is not the same as the $modal service used above.
- app.controller('ModalInstanceCtrl', function ($scope, $modalInstance, items) {
- $scope.items = items;
- $scope.selected = {
- item: $scope.items[0]
- };
- $scope.ok = function () {
- $modalInstance.close($scope.selected.item);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement