A Pen by Iván Álvarez on CodePen.
Created
September 16, 2015 18:21
-
-
Save davidmaogomezz/0c2099f3cc9472ec9eeb to your computer and use it in GitHub Desktop.
Ionic Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html ng-app="mySuperApp"> | |
<head> | |
<meta charset="utf-8"> | |
<title> | |
Popups | |
</title> | |
<!-- Sets initial viewport load and disables zooming --> | |
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"> | |
<link href="http://code.ionicframework.com/1.0.0-beta.9/css/ionic.css" rel="stylesheet"> | |
<script src="http://code.ionicframework.com/1.0.0-beta.9/js/ionic.bundle.js"> | |
</script> | |
</head> | |
<body class="padding" ng-controller="PopupCtrl"> | |
<ion-header-bar class="bar-positive"> | |
<div class="buttons"> | |
<button class="button button-icon icon ion-ios7-minus-outline" | |
ng-click="data.showDelete = !data.showDelete; data.showReorder = false"></button> | |
<h1 class="title">Ionic Delete/Option Buttons</h1> | |
</div> | |
</ion-header-bar> | |
<ion-content> | |
<ion-list show-delete="true"> | |
<ion-item ng-repeat="item in items" href="#" ng-click="show(item)" item-type="item item-icon-left"> | |
Hello {{item.name}}! | |
<ion-delete-button class="ion-minus-circled"></ion-delete-button> | |
<ion-option-button class="button-positive" | |
ng-click="edit(item)"> | |
Edit | |
</ion-option-button> | |
</ion-item> | |
</ion-list> | |
<button class="button button-dark" ng-click="showPopup()"> | |
show | |
</button> | |
<button class="button button-primary" ng-click="showConfirm()"> | |
Confirm | |
</button> | |
<button class="button button-positive" ng-click="showAlert()"> | |
Alert | |
</button> | |
<ion-list> | |
<ion-item> | |
I love kittens! | |
<ion-option-button class="button-positive">Share</ion-option-button> | |
<ion-option-button class="button-assertive">Edit</ion-option-button> | |
</ion-item> | |
</ion-list> | |
<script id="popup-template.html" type="text/ng-template"> | |
<input ng-model="data.wifi" type="text" placeholder="Password"> | |
</script> | |
</ion-content> | |
</body> | |
</html> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('mySuperApp', ['ionic']) | |
.controller('PopupCtrl',function($scope, $ionicPopup, $timeout, $ionicActionSheet) { | |
$scope.items = [ | |
{name: "Iván"}, | |
{name: "Lucía"} | |
]; | |
$scope.edit = function(item){ | |
alert(item.name); | |
} | |
// Triggered on a button click, or some other target | |
$scope.show = function() { | |
// Show the action sheet | |
var hideSheet = $ionicActionSheet.show({ | |
buttons: [ | |
{ text: '<b>Share</b> This' }, | |
{ text: 'Move' } | |
], | |
destructiveText: 'Delete', | |
titleText: 'Modify your album', | |
cancelText: 'Cancel', | |
buttonClicked: function(index) { | |
return true; | |
} | |
}); | |
// For example's sake, hide the sheet after two seconds | |
$timeout(function() { | |
hideSheet(); | |
}, 2000); | |
}; | |
// Triggered on a button click, or some other target | |
$scope.showPopup = function() { | |
$scope.data = {} | |
// An elaborate, custom popup | |
var myPopup = $ionicPopup.show({ | |
template: '<input type="password" ng-model="data.wifi">', | |
title: 'Enter Wi-Fi Password', | |
subTitle: 'Please use normal things', | |
scope: $scope, | |
buttons: [ | |
{ text: 'Cancel' }, | |
{ | |
text: '<b>Save</b>', | |
type: 'button-positive', | |
onTap: function(e) { | |
if (!$scope.data.wifi) { | |
//don't allow the user to close unless he enters wifi password | |
e.preventDefault(); | |
} else { | |
return $scope.data.wifi; | |
} | |
} | |
}, | |
] | |
}); | |
myPopup.then(function(res) { | |
console.log('Tapped!', res); | |
}); | |
$timeout(function() { | |
myPopup.close(); //close the popup after 3 seconds for some reason | |
}, 3000); | |
}; | |
// A confirm dialog | |
$scope.showConfirm = function() { | |
var confirmPopup = $ionicPopup.confirm({ | |
title: 'Consume Ice Cream', | |
template: 'Are you sure you want to eat this ice cream?' | |
}); | |
confirmPopup.then(function(res) { | |
if(res) { | |
console.log('You are sure'); | |
} else { | |
console.log('You are not sure'); | |
} | |
}); | |
}; | |
// An alert dialog | |
$scope.showAlert = function() { | |
var alertPopup = $ionicPopup.alert({ | |
title: 'Don\'t eat that!', | |
template: 'It might taste good' | |
}); | |
alertPopup.then(function(res) { | |
console.log('Thank you for not eating my delicious ice cream cone'); | |
}); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment