my modal:
<div class="modal">
<!-- Modal header bar -->
<ion-header-bar class="bar-secondary ">
<h1 class="title ">New Task</h1>
<button class="button button-clear button-positive " ng-click="closeNewTask() ">Cancel</button>
</ion-header-bar>
<!-- Modal content area -->
<ion-content>
<form ng-submit="">
<div class="list ">
<div class="item">
<label class="item item-input ">
<input type="text " placeholder="What do you need to do? ">
<button type="button" class="button button-icon" ng-click="openPopover($event)">
<i class="icon ion-information-circled red font-size-25"></i>
</button>
</label>
</div>
</div>
<div class="padding ">
<button type="submit" class="button button-block button-positive ">Create Task</button>
</div>
</form>
</ion-content>
</div>
this is my modal it works fine but the "icon information" inside the modal doesn't work ... i put a $ionicPopover in the controller and the functions
var template = '<ion-popover-view><ion-header-bar> <h1 class="title">My Popover Title</h1> </ion-header-bar> <ion-content> Hello! </ion-content></ion-popover-view>';
$scope.popover = $ionicPopover.fromTemplate(template, {
scope: $scope
});
$scope.openPopover = function($event) {
$scope.popover.show($event);
};
everythink works good out of the modal , but inside not
$scope.openPopover = function($event) {
$scope.popover.show($event);
};
change it to
$scope.openPopover = function(e) {
$scope.popover.show(e);
};
Related
I'm working on an Ionic 1 project. I'm trying to have a nav-bar with a back button inside one of the views, but its not appearing. I inspected on Chrome, and saw that the class of the back button became hide. Is there anyway I can make it appear?
Here's my code:
<ion-view ng-controller="GuDetailCtrl">
<ion-nav-bar class="bar-positive">
<ion-nav-back-button class="button-icon ion-arrow-left-c show">
</ion-nav-back-button>
</ion-nav-bar>
<ion-content class="padding">
<div class="list">
<label class="item item-input">
<span class="input-label">Name</span>
<span>{{hotel.name}}</span>
</label>
<label class="item item-input">
<span class="input-label">Locality</span>
<span>{{hotel.locality}}</span>
</label>
<label class="item item-input">
<span class="input-label">Amenities</span>
<span>{{hotel.amenities}}</span>
</label>
</div>
<button class="button button-positive" ng-click="modal.show()">
Create Booking
</button>
<script id="templates/booking.html" type="text/ng-template">
<ion-modal-view>
<ion-header-bar class="bar bar-header bar-positive">
<h1 class="title">New Booking</h1>
<button class="button button-clear button-primary" ng-click="modal.hide()">Cancel</button>
</ion-header-bar>
<ion-content class="padding">
<div class="list">
<label class="item item-input">
<span class="input-label">Check-in Date</span>
<input ng-model="newBooking.inDate" type="date">
</label>
<label class="item item-input">
<span class="input-label">Check-out Date</span>
<input ng-model="newBooking.outDate" type="date">
</label>
<label class="item item-input">
<span class="input-label">No. of Rooms</span>
<input ng-model="newBooking.rooms" type="number">
</label>
<button class="button button-full button-positive" ng-click="createBooking(newBooking)">Create</button>
</div>
</ion-content>
</ion-modal-view>
</script>
</ion-content>
</ion-view>
You can try this code.The header has a class by default, if you don't explicitly specify one, then the back button won't show up. you can use bar-light or bar-royal in your class.
<ion-nav-bar class="bar-royal">
<ion-nav-back-button>Back</ion-nav-back-button>
</ion-nav-bar>
for more, You can see here
I have a simple modal form to get comment. When the Submit button or the Close button is clicked, the modal form is supposed to close, but it doesn't.
The following is code snippet from my controller:
$ionicModal.fromTemplateUrl('templates/sharing-comment.html', {
scope: $scope
}).then(function (modal) {
$scope.commentForm = modal;
});
// Triggered in the comment modal to close it
$scope.closeCommentForm = function () {
$scope.commentForm.hide();
};
// Open the comment modal
$scope.showCommentForm = function () {
$scope.commentForm.show();
$scope.popover.hide();
};
The following is code snippet from my modal form:
<ion-modal-view>
<ion-header-bar>
<h1 class="title">Submit Comment on Sharing</h1>
<div class="buttons">
<button class="button button-clear" ng-
click="closeCommentForm()">Close</button>
</div>
</ion-header-bar>
<ion-content>
<form id="commentForm" name="commentForm" ng-submit="submitComment()">
<div class="list">
<label class="item item-input">
<span class="input-label">Your Comment</span>
<textarea type="text" ng-model="mycomment.comment"></textarea>
</label>
<label class="item">
<button class="button button-block button-positive"
type="submit">Submit</button>
</label>
</div>
</form>
</ion-content>
</ion-modal-view>
Try this, I made codepen for you
angular.module('ionicApp', ['ionic'])
.controller('AppCtrl', function($scope, $ionicModal) {
$ionicModal.fromTemplateUrl('templates/modal.html', {
scope: $scope
}).then(function(modal) {
$scope.commentForm = modal;
});
$scope.createContact = function() {
$scope.commentForm.hide();
};
});
<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>Ionic Modal</title>
<link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
<script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
</head>
<body ng-controller="AppCtrl">
<ion-header-bar class="bar-positive">
<h1 class="title">Contacts</h1>
<div class="buttons">
<button class="button button-icon ion-compose" ng-click="commentForm.show()">
</button>
</div>
</ion-header-bar>
<script id="templates/modal.html" type="text/ng-template">
<ion-modal-view>
<ion-header-bar class="bar bar-header bar-positive">
<h1 class="title">New Contact</h1>
<button class="button button-clear button-primary" ng-click="commentForm.hide()">Cancel</button>
</ion-header-bar>
<ion-content class="padding">
<div class="list">
<label class="item item-input">
<span class="input-label">First Name</span>
<input ng-model="newUser.firstName" type="text">
</label>
<label class="item item-input">
<span class="input-label">Last Name</span>
<input ng-model="newUser.lastName" type="text">
</label>
<label class="item item-input">
<span class="input-label">Email</span>
<input ng-model="newUser.email" type="text">
</label>
<button class="button button-full button-positive" ng-click="createContact(newUser)">Create</button>
</div>
</ion-content>
</ion-modal-view>
</script>
</body>
</html>
I am using copy paste code from ionic docs for header inputs
http://ionicframework.com/docs/components/#bar-inputs
<div class="bar bar-header item-input-inset">
<label class="item-input-wrapper">
<i class="icon ion-ios-search placeholder-icon"></i>
<input type="search" placeholder="Search">
</label>
<button class="button button-clear">
Cancel
</button>
</div>
But I am not seeing it.
I only want my header to be a search bar in one view.
Heres the views code beginning:
<ion-view>
<div class="bar bar-header item-input-inset">
<label class="item-input-wrapper">
<i class="icon ion-ios-search placeholder-icon"></i>
<input type="search" placeholder="Search">
</label>
<button class="button button-clear">
Cancel
</button>
</div>
<ion-content>
...
You can add Header Inputs two way
1) Add in index.html
<div class="bar bar-header item-input-inset">
<label class="item-input-wrapper">
<i class="icon ion-ios-search placeholder-icon"></i>
<input type="search" placeholder="Search">
</label>
<button class="button button-clear">
Cancel
</button>
</div>
<ion-nav-view></ion-nav-view>
2) Add in index.html
<ion-nav-view></ion-nav-view>
and in your template page(e.g. template/home.html)
<ion-view>
<div class="bar bar-header item-input-inset">
<label class="item-input-wrapper">
<i class="icon ion-ios-search placeholder-icon"></i>
<input type="search" placeholder="Search">
</label>
<button class="button button-clear">
Cancel
</button>
</div>
<ion-content>
...
</ion-content>
</ion-view>
Demo
Just try to implement pull to refresh from ionic framework, but it does not work, the icon just keep showing and nothing happen.
Anyone can point where is the problem?
Here is the code.
lists.html
<ion-header-bar align-title="center" class="bar-stable">
<h1 class="title">Latest Items</h1>
<button class="button button-clear button-positive" ui-sref="addlist">New</button>
</ion-header-bar>
<ion-view title="Terbaru">
<ion-content>
<ion-refresher on-refresh="doRefresh()">
pulling-text="Pull to refresh..."
</ion-refresher>
<label class="item item-input">
<i class="icon ion-search placeholder-icon"></i>
<input type="text" name="dash.search" value="" placeholder="Search">
</label>
<div class="list card" ng-repeat="x in data" type="item-text-wrap" href="#/tab/chat/{{x.id}}">
<div class="item item-avatar">
<img data-ng-src="data:image/png;base64,{{x.photopath}}">
<h2>{{x.title}}</h2>
<p>{{x.tgl}}</p>
</div>
<div class="item item-body">
<img class="full-image" data-ng-src="data:image/jpeg;base64,{{x.imagepath}}">
<p>
{{x.descr}}
</p>
<p>
1 Like
5 Comments
</p>
</div>
</div>
</ion-content>
</ion-view>
controller.js
angular.module('ionicApp.controllers', [])
.controller('AddListCategoryCtrl', function($scope, $http) {
var xhr = $http({
method: 'post',
url: 'http://www.mywebsite.com/api/listCat.php'
});
xhr.success(function(data){
$scope.data = data.data;
});
$scope.doRefresh = function(){
$http.get('http://www.mywebsite.com/api/lists.php')
.success(function(data){
$scope.data=data.data;
console.log($scope.data);
})
.finally(function(){
$scope.$broadcast('scroll.refreshComplete');
$scope.$apply()
});
}
});
There is an error in your code. Pulling text should be an attribute of ion-refresher.
This is the correct code:
<ion-refresher on-refresh="doRefresh()" pulling-text="Pull to refresh...">
</ion-refresher>
You added the closing tag before the pulling-text attribute.
I am trying to implement a simple page with a login form (user/password text input + 1 button). I would like to fix this form to the bottom of a ion-content. But it does not work.
HTML:
<ion-view hide-nav-bar="true">
<ion-content padding="true">
<img class="logo" src="img/logo.jpeg" />
<div class="login-form">
<div class="list">
<label class="item item-input light-text-input">
<input type="text" placeholder="user" ng-model="user">
</label>
<label class="item item-input light-text-input">
<input type="text" placeholder="password" ng-model="password">
</label>
</div>
<div class="row">
<div class="col">
<button class="button button-block button-energized">Login</button>
</div>
<div class="col">
<button class="button button-block button-positive">FB Login</button>
</div>
</div>
<p class="text-center">Forgot password</p>
</div>
</ion-content>
I would like to set as "fixed" the div.login-form.
Using the following CSS does not work:
{
position: fixed;
bottom: 20px;
}
Also, with position:fixed input texts seem no more editable.
In Ionic, is it possible to fix part of the content to bottom?
Thx!
You could use anythnig out the ion-content with a button inside of it.
Demo
<ion-list>
<ion-item ng-repeat="item in items"
item="item"
href="#/item/{{item.id}}">
Item {{ item.id }}
</ion-item>
</ion-list>
</ion-content>
<div class="fixed-outside">
<div class="row">
<div class="col">
<button class="button button-circle button-energized icon ion-log-in"></button>
</div>
<div class="col">
<button class="button button-circle button-positive icon ion-social-facebook"></button>
</div>
</div>
<p class="text-center">Forgot password</p>
</div>
</div>
How about just using the default ionic tab bar and just change the height to auto or any px that you wishes. Just make sure you put the code below ion-content tag.
Code:
<ion-content padding="true">
</ion-content>
<div class="tabs tabs-dark" style="height:auto;">
<div class="row">
<div class="col">
<div class="list">
<label class="item item-input">
<span class="input-label">Username</span>
<input type="text">
</label>
<label class="item item-input">
<span class="input-label">Password</span>
<input type="password" >
</label>
</div>
<div class="row">
<div class="col">
<button class="button button-block button-positive">LOGIN</button>
</div>
</div>
</div>
</div>
</div>
Codepen example : http://codepen.io/ridwan/pen/JozeYK
You could use a directive to calculate the height of the form. It will recalculate on window resize. I haven't tested navigating away from the page.
Codepen
Relevant HTML
<ion-view hide-nav-bar="true" ng-controller="MainCtrl">
<ion-content padding="true" scroll="false">
<ion-scroll scroll-height>
Content to go above the form
</ion-scroll>
<div class="login-form">
Login form
</div>
</ion-content>
</ion-view>
CSS
.scroll-content {
position: relative;
}
div.login-form {
position: fixed;
left: 0;
right: 0;
bottom: 0;
}
Directive
.directive('scrollHeight', function($window) {
return {
link: function(scope, element, attrs) {
scope.onResize = function() {
var winHeight = $window.innerHeight;
var form = angular.element(document.querySelector('.login-form'))[0];
var formHeight = form.scrollHeight;
var scrollHeight = winHeight - formHeight;
element.css("height", scrollHeight + "px");
}
scope.onResize();
angular.element($window).bind('resize', function() {
scope.onResize();
})
}
}
})
all the elements which you want to have fixed in the bottom should be out of the ion-content. This is a working example:
<ion-view title="Test" hide-nav-bar="true">
<ion-content class="padding">
<img class="logo" src="img/logo.jpeg" />
</ion-content>
<!-- align to the bottom of the page -->
<div class="login-form" style="position: absolute; bottom: 0px; width: 100%">
<div class="list">
<label class="item item-input light-text-input">
<input type="text" placeholder="user" ng-model="user">
</label>
<label class="item item-input light-text-input">
<input type="text" placeholder="password" ng-model="password">
</label>
</div>
<div class="row">
<div class="col">
<button class="button button-block button-energized">Login</button>
</div>
<div class="col">
<button class="button button-block button-positive">FB Login</button>
</div>
</div>
<p class="text-center">Forgot password</p>
</div>
I just find a simple solution, which works fine for me.
<ion-content>
<ion-scroll style="height: 300px">
<div style="height: 1000px">
your scroll content
</div>>
</ion-scroll>
<div>
your fixed div, maybe a form
</div>
</ion-content>
you can also refer to: http://ionicframework.com/docs/api/directive/ionScroll/
I hope it helps.
I ended up more or less circumventing Ionic's intentions and using a flex box layout:
<ion-view view-title="My Title" class="flex-wrapper" hide-nav-bar="true">
<div class="flex-head"> ... </div>
<div class="flex-body flex-1"> ... </div>
<div class="flex-foot"> ... </div>
</ion-view>
The SCSS, using Ionic's mixins, looks something like this:
.flex-wrapper {
#include display-flex;
#include flex-direction(column);
...
}
.flex-1 {
#include flex(1);
...
}
actually i am using the version Ionic 2.0.0 i resolve with this code
<ion-fixed class="fixed">
<button fab fab-right fab-bottom>
${{ totalPrice }}
</button>
</ion-fixed>
in your File Scss
.fixed {
bottom: 50px;
right: 10px;
}