Skip to content

Instantly share code, notes, and snippets.

@trq
Last active August 29, 2015 14:06
Show Gist options
  • Save trq/86b8f6fd11b76e8997f7 to your computer and use it in GitHub Desktop.
Save trq/86b8f6fd11b76e8997f7 to your computer and use it in GitHub Desktop.
(function() {
var calculator = angular.module('calculator', ['ui.check', 'ui.tick', 'mm.foundation', 'mm.foundation.tooltip', 'mm.foundation.modal']);
calculator.controller('ModalInstanceCtrl', ['$scope', '$modalInstance', function($scope, $modalInstance, email) {
$scope.user = {
email = email
}
$scope.ok = function () {
$modalInstance.close($scope.user.email);
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}]);
calculator.controller('FormCtrl', ['$scope', '$http', '$modal', '$log', function($scope, $http, $modal, $log) {
$scope.plans = [];
$scope.email = null;
$scope.saveCalculator = function () {
var json = {
selections: $scope.selections,
discounts: $scope.discounts,
results: $scope.results
}
var modalInstance = $modal.open({
templateUrl: 'email-modal.html',
controller: 'ModalInstanceCtrl',
resolve: {
email: function () {
return $scope.email;
}
}
});
modalInstance.result.then(function (email) {
$scope.email = email;
$log.info('userEmail: ' + $scope.email);
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
};
}]);
})();
<div ng-app="calculator" ng-controller="FormCtrl">
<div ng-show="page2" class="holder_btn">
<button ng-click="saveCalculator()" class="buttons grey send">Send to my email</button>
</div>
<script type="text/ng-template" id="email-modal.html">
<h3>Please enter your email address.</h3>
<input type="text" ng-model="user.email" placeholder="[email protected]" />
<button class="button" ng-click="ok()">Send</button>
<a class="close-reveal-modal" ng-click="cancel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment