i am trying to create a login application with create account option.When i run the ionic serve i get a white screen.
Heres code i have done so far
(am totally new to this stuff )
index.html
<body ng-app="starter">
<ion-nav-view></ion-nav-view>
</body>
login.html
<ion-view>
<ion-content>
<div class="login-image">
<img src="../img/img3.jpg" width="100%" class="padding">
</div>
<div class="padding">
<form ng-submit="doLogin()" >
<div class="list">
<label class="item item-input">
<span class="input-label"></span>
<input type="text" ng-model="loginData.username" placeholder="Username">
</label><br>
<label class="item item-input">
<span class="input-label"></span>
<input type="password" ng-model="loginData.password" placeholder="Password">
</label><br>
<div style=" text-align: right;">
Forgot Password
</div><br>
<label>
<button class="button button-block button-positive" type="submit" href = "template/dashboard.html">Log in</button>
</label>
<br>
<div style=" text-align: center;">
Create Account
</div>
</div>
</form>
</div>
</ion-content>
</ion-view>
createaccount.html
<ion-view>
<ion-content>
<div>
<form name="createaccountform" class="padding">
<div>
<label class="item item-input item-floating-label">
<span class="input-label">First Name</span>
<input type="text" name="firstname" placeholder="First Name">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Last Name</span>
<input type="text" name="lastname" placeholder="Last Name">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Email</span>
<input type="email" name="email" placeholder="Email">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Username</span>
<input type="text" name="Username" placeholder="Username">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Password</span>
<input type="password" name="password" placeholder="Password">
</label>
<label>
<button class="button button-block button-positive" type="submit" href="template/login.html">Create Account </button>
</label>
</div>
</form>
</div>
</ion-content>
</ion-view>
app.js
.config(function($stateProvider,$urlRouterProvider){
$stateProvider
.state('index',{
url: '/index',
abstract: true,
templateUrl: '/index.html'
})
.state('login',{
url: '/login',
templateUrl: 'templates/login.html'
})
.state('createaccount',{
url: '/createaccount',
templateUrl: 'templates/createaccount.html'
});
//allows for fallback when page not found or not exist
$urlRouterProvider.otherwise('templates/login.html');
});
Dont know what am dong wrong but i really need a guide on this.
After of run your command, need to access to the following URL to see your login page:
http://localhost:8000/login
The routing is handled in your app.js file throughout state manager.
I suggest taking at look at the official documentation to understand how works.
Her's the HTML code
<ion-view view-title="Reviewer Title">
<ion-content>
<div class="content no-header">
<ion-nav-bar class="bar-assertive-900" align-title="left">
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-android-arrow-back" ui-sref="app.reviewers"> </button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button class="button button-icon button-clear ion-android-done-all"
ng-click="edtRv.edit(edtRv.e[0].id,qs_id,chs_id, rv_object,qs_object,chs_object)"> </button>
<button class="button button-icon button-clear ion-trash-b"> </button>
</ion-nav-buttons>
</ion-nav-bar>
<br> <br> <br>
<div class="blk">
<input type="text" value="{{edtRv.e[0].rev_name}}" >
</div>
<div class="button-bar">
<a class="button button-outline button-assertive" ng-click="showCard()"> show all</a>
<a class="button button-outline button-assertive" ng-click="hideCard()"> hide all</a>
</div>
<form ng-repeat="edit in edtRv.e">
<ion-item ng-if="edit.question_type_id == 1">
<ion-checkbox ng-if=""> </ion-checkbox>
<div class="list list-inset">
<div>
Rv id{{edit.id}}
Qstn id{{edit.id1}}
Chs id{{edit.id2}}
<label class="item item-input">
<b><span class="input-label item-num"> {{$index+1}}.) </span> </b>
<input type="text" ng-value="edit.question">
</label>
</div>
<div id="startCard" ng-show="showstartCard">
<label class="item item-input">
<b><span class="input-label item-num"> Answer: </span> </b>
<input type="text" ng-value="edit.answer">
</label>
</div>
</div>
</ion-item>
<ion-item ng-if="edit.question_type_id == 2">
<ion-checkbox ng-if=""> </ion-checkbox>
<div class="list list-inset">
<div>
Rv id{{edit.id}}
Qstn id{{edit.id1}}
Chs id{{edit.id2}}
<label class="item item-input">
<b><span class="input-label item-num"> {{$index+1}}.) </span> </b>
<input type="text" ng-value="edit.question">
</label>
</div>
<div id="startCard" ng-show="showstartCard">
<label class="item item-input">
<b><span class="input-label item-num"> Answer: </span></b>
<input type="text" ng-value="edit.answer">
</label>
<label class="item item-input">
<b><span class="input-label item-num"> choice 1: </span></b>
<input type="text" ng-value="edit.choice_1">
</label>
<label class="item item-input">
<b><span class="input-label item-num"> choice 2: </span></b>
<input type="text" ng-value="edit.choice_2">
</label>
<label class="item item-input">
<b><span class="input-label item-num"> choice 3: </span></b>
<input type="text" ng-value="edit.choice_3">
</label>
</div>
</div>
</ion-item>
</form>
</ion-content>
What Im trying to do is to update the reviewers title the questions and the choices that follow with just one function or one button in the view.I don't want button each item so is there's a way on how to do this?Thank you :D
Here's the Service file
service.update = function (rv_id,qs_id,chs_id, rv_object,qs_object,chs_object) {
// return $http.put(getUrlForId(id), object);
// for updating rev object
return $http.put(getRevUrlForId(rv_id), rv_object)
.then(function (result) {
console.log(result.data);
});
// for updating qstn object
return $http.put(getQsUrlForId(qs_id), qs_object)
.then(function (result) {
console.log(result.data);
});
// for updating chs object
return $http.put(getChoicesUrlForId(chs_id), chs_object)
.then(function (result) {
console.log(result.data);
});
};
Here's the controller
.controller('EditRevCtrl', function($scope, $timeout, $stateParams, $ionicPopup, ionicMaterialInk, ItemsModel, Backand) {
var edtRv = this;
edtRv.e = ItemsModel.getcontForEdit(); // use for getting reviewers info
function edit (rv_id,qs_id,chs_id, rv_object,qs_object,chs_object) {
ItemsModel.update(rv_id,qs_id,chs_id, rv_object,qs_object,chs_object);
}
})
Certainly!
First you should inject $q into your service as we will use it below.
Using Q you can pass an array of promises to be resolved.
service.update = function (rv_id,qs_id,chs_id, rv_object,qs_object,chs_object) {
return $q.all([
$http.put(getUrlForId(id), object),
$http.put(getRevUrlForId(rv_id), rv_object),
$http.put(getQsUrlForId(qs_id), qs_object),
$http.put(getChoicesUrlForId(chs_id), chs_object),
]).then(function(results) {
var UrlForId = results[0];
var RevUrlForId = results[1];
var QsUrlForId= results[2];
var ChoicesUrlForId= results[3];
return results;
})
};
I am try to store an object into LocalStorage, but when I triggersetItem, its store two objects (duplicate). Below are my codes;
html
<form class="clearBoth" ng-submit="addProject(projectInfo)">
<div class="list" ng-model="projectInfo">
<label class="item item-input item-stacked-label">
<span class="input-label">Project Name</span>
<input type="text" ng-model="projectInfo.name" placeholder="PSN" required>
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Host</span>
<input type="text" ng-model="projectInfo.host" placeholder="http://psn.com.my" required>
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Instance</span>
<input type="text" ng-model="projectInfo.instance" placeholder="PSN" required>
</label>
</div>
<button class="button button-block button-positive" ng-click="addProject(projectInfo)">Block Button</button>
<button class="button button-block button-assertive" ng-click="removeProject()">Block Button</button>
</form>
controller
.controller("ProjectAddCtrl", function($scope) {
$scope.addProject = function (projectInfo) {
var oldItems = JSON.parse(localStorage.getItem('itemsArray')) || [];
$scope.projects = [{
name: "",
host: "",
instance: ""
}];
oldItems.push(projectInfo);
localStorage.setItem('itemsArray', JSON.stringify(oldItems));
};
$scope.removeProject = function () { localStorage.clear(); };
console.log(JSON.parse(localStorage.getItem('itemsArray')));
})
Both ng-click on the <button> and ng-submit on the <form> are being triggered and hence, you are seeing the same data being added twice. You can fix it by adding type="button" attribute on the first button.
Check documentation - the default value for the type attribute is submit and hence, both the click and submit events are being fired.
Issue: I have a simple add item form that adds a picture from the phone's album in a view. For some reason, after adding ion-content scroll="true", the page still doesn't allow for scrolling.
Also, I've set $ionicScrollDelegate to refresh in the controller. Thanks!
<ion-view title="Add Item">
<ion-nav-bar class="bar-positive">
<ion-nav-back-button class="button-clear">
<i class="ion-arrow-left-c"></i> Back
</ion-nav-back-button>
</ion-nav-bar>
<ion-content scroll="true">
<!-- <ion-scroll direction="y" style="height: 800px;"> -->
<ion-pane>
<div class="row">
<div class="col text-center">
<button class="button button-calm" ng-click="getPhoto()"><i class="ion-camera"></i> Select Photo</button>
</div>
</div>
<div class="list card" ng-show="item.pic">
<div class="item">
<img class="full-image" src="data:image/jpg;base64,{{item.pic}}">
</div>
</div>
<form ng-submit="submitItem()" name="newItemForm" novalidate>
<label class="item item-input">
<span class="input-label" type="text">* Designer: </span>
<input type="text" ng-model="item.designer" ng-required="true">
</label>
<label class="item item-input">
<span class="input-label" type="text">* Type/Collection: </span>
<input type="text" ng-model="item.collection" ng-required="true">
</label>
<p ng-show="newItemForm.item.collection.$error.required">Type/Collection Required</p>
<label class="item item-input">
<span class="input-label" type="text">* Color: </span>
<input type="text" ng-model="item.color" ng-required="true">
</label>
<label class="item item-input">
<span class="input-label" type="text">* Size: </span>
<input type="text" ng-model="item.size" ng-required="true">
</label>
<label class="item item-input">
<span class="input-label" type="text">Material: </span>
<input type="text" ng-model="item.material">
</label>
<label class="item item-input">
<span class="input-label" type="text">* Condition: </span>
<input type="text" ng-model="item.condition" ng-required="true">
</label>
<label class="item item-input">
<span class="input-label" type="text">* Description: </span>
<textarea type="text" ng-model="item.description" ng-required="true"></textarea>
</label>
<p ng-show="newItemForm.$invalid" class="warning">*Items must be filled in to Add Item</p>
<div class="row">
<div class="col text-center">
<button type="submit" class="button button-balanced" ng-disabled="newItemForm.$invalid"><i class="ion-plus"></i> Add Item</button>
</div>
</div>
</form>
</ion-pane>
<!-- </ion-scroll> -->
</ion-content>
</ion-view>
I am using radio buttons in a popover to create a dropdown type filter for my app.
When I use an iPad the radio buttons go haywire! This works perfectly on every other device.
Best illustration is in this video
https://www.youtube.com/watch?v=Begkz4uS8hQ
Here is my code:
<script id="templates/popover.html" type="text/ng-template">
<ion-popover-view>
<ion-content>
<div class="item bar-header bar-positive">
<h2 class="title">Difficulty</h2>
</div>
<label class="item item-radio">
<input type="radio" ng-model="filter.difficulty" value="" name="group">
<div class="item-content">
All
</div>
<i class="radio-icon ion-checkmark"></i>
</label>
<label class="item item-radio">
<input type="radio" ng-model="filter.difficulty" value="Easy" name="group">
<div class="item-content">
Easy
</div>
<i class="radio-icon ion-checkmark"></i>
</label>
<label class="item item-radio">
<input type="radio" ng-model="filter.difficulty" value="Medium" name="group">
<div class="item-content">
Medium
</div>
<i class="radio-icon ion-checkmark"></i>
</label>
<label class="item item-radio">
<input type="radio" ng-model="filter.difficulty" value="Hard" name="group">
<div class="item-content">
Hard
</div>
<i class="radio-icon ion-checkmark"></i>
</label>
<label class="item item-radio">
<input type="radio" ng-model="filter.difficulty" value="Expert" name="group">
<div class="item-content">
Expert
</div>
<i class="radio-icon ion-checkmark"></i>
</label>
</ion-content>
</ion-popover-view>
</script>
And displayed using this:
<button class="button button-positive button-small col col-20 icon-left ion-connection-bars filter-button" ng-click="popover.show($event)">
{{filter.difficulty || 'All'}}
</button>
Many thanks to anyone who can help.