AngularJS UI-Router edit page title - angularjs

I'm working on an AngularJs application with symfony 2.8 backoffice. I want to edit the contact page title. This is the code of the contact page :
<div ng-controller="contactFormCtrl">
<fieldset>
<h1 translate="front.CONTACT">Contact</h1>
<h2 ng-bind-html="post.content"></h2>
<form name="contactForm" id="contactForm" class="form" data-ng-submit="submitForm(contactForm)">
<div class="form-group" ng-class="{'has-error':contactForm.firstName.$dirty && contactForm.firstName.$invalid, 'has-success':contactForm.firstName.$valid}">
<label for="contactFirstName" class="control-label">
<span translate="content.list.fields.FIRSTNAME">First Name</span>
<span class="symbol required"></span>
</label>
<span class="input-icon">
<input name="firstName" id="contactFirstName" ng-model="contact.firstName" type="text" class="form-control" name="firstName" placeholder="[[ 'content.list.fields.FIRSTNAME' | translate ]]" ng-required="true">
<i class="fa fa-user"></i>
</span>
<span class="error text-small block" ng-if="contactForm.firstName.$dirty && contactForm.firstName.$error.required" translate="content.form.messages.FIRSTNAMEREQUIRED">FirstName is required.</span>
</div>
<div class="form-group" ng-class="{'has-error':contactForm.lastName.$dirty && contactForm.lastName.$invalid, 'has-success':contactForm.lastName.$valid}">
<label for="contactLastName" class="control-label">
<span translate="content.list.fields.LASTNAME">Last Name</span>
<span class="symbol required"></span>
</label>
<span class="input-icon">
<input name="lastName" id="contactLastName" ng-model="contact.lastName" type="text" class="form-control" name="lastName" placeholder="[[ 'content.list.fields.LASTNAME' | translate ]]" ng-required="true">
<i class="fa fa-user-o"></i>
</span>
<span class="error text-small block" ng-if="contactForm.lastName.$dirty && contactForm.lastName.$error.required" translate="content.form.messages.LASTNAMEREQUIRED">LastName is required.</span>
</div>
<div class="form-group" ng-class="{'has-error':contactForm.contactEmail.$dirty && contactForm.contactEmail.$invalid, 'has-success':contactForm.contactEmail.$valid}">
<label for="contactEmail" class="control-label">
<span translate="content.list.fields.EMAIL">Email</span>
<span class="symbol required"></span>
</label>
<span class="input-icon">
<input name="contactEmail" id="contactEmail" ng-model="contact.email" type="email" class="form-control" name="email" placeholder="[[ 'content.list.fields.EMAIL' | translate ]]" ng-required="true">
<i class="fa fa-envelope-o"></i>
</span>
<span class="error text-small block" ng-if="contactForm.contactEmail.$dirty && contactForm.contactEmail.$error.required" translate="content.form.messages.EMAILREQUIRED">Email is required.</span>
</div>
<div class="form-group" ng-class="{'has-error':contactForm.contactSubject.$dirty && contactForm.contactSubject.$invalid, 'has-success':contactForm.contactSubject.$valid}">
<label for="contactSubject" class="control-label">
<span translate="content.list.fields.SUBJECT">Subject</span>
<span class="symbol required"></span>
</label>
<span class="input-icon">
<input name="contactSubject" id= "contactSubject" ng-model="contact.subject" type="text" class="form-control" name="contactSubject" placeholder="[[ 'content.list.fields.SUBJECT' | translate ]]" ng-required="true">
<i class="ti-marker-alt"></i>
</span>
<span class="error text-small block" ng-if="contactForm.contactSubject.$dirty && contactForm.contactSubject.$error.required" translate="content.form.messages.SUBJECTREQUIRED">Subject is required.</span>
</div>
<div class="form-group" ng-class="{'has-error':contactForm.contactMessage.$dirty && contactForm.contactMessage.$invalid, 'has-success':contactForm.contactMessage.$valid}">
<label for="contactMessage" class="control-label">
<span translate="content.list.fields.MESSAGE">Message</span>
<span class="symbol required"></span>
</label>
<span class="input-icon">
<textarea name="contactMessage" id="contactMessage" ng-model="contact.message" rows="10" class="form-control" name="contactMessage" placeholder="[[ 'content.list.fields.MESSAGE' | translate ]]" ng-required="true"></textarea>
<i class="fa fa-message-o"></i>
</span>
<span class="error text-small block" ng-if="contactForm.contactMessage.$dirty && contactForm.contactMessage.$error.required" translate="content.form.messages.CONTACTMESSAGEREQUIRED">Message is required.</span>
</div>
<button type="button" ng-click="submitForm(contactForm)" class="btn btn-primary pull-right" ng-disabled="disableSubmit"> <!-- ng-disabled="userForm.$invalid" -->
<i class="fa fa-spinner fa-spin" ng-if="disableSubmit"></i><i class="fa fa-envelope" ng-if="!disableSubmit"></i> <span translate="content.common.SEND">Send</span>
</button>
</form>
when i use the inspector i find this function :
<title ng-bind="pageTitle()" class="ng-binding">E-electricity</title>
A function called pageTitle() to automatically generate a title for each page. i want to edit E-electricity to E-electricity-contact.

Related

ng-submit is not working in AngularJs while controller is properly working

I am relatively new to AngularJs. I am creating a website and there are several forms on the website. The same code with ng-submit is working on other pages. But not here.
The controller, ng-options and validations are working properly.
I tried changing function and checking the function
<div class="row" ng-controller="PostspaceFormController as LoginFormCtrl">
<div class="divider-30 d-none d-lg-block"></div>
<form class="form-styling" name="LoginForm" ng-submit="submitDataInForm3()" novalidate>
<fieldset ng-disabled="sendingMail">
<p class="fs-l-17 fw-l-500 margin-styling">Post Your Space Requirement</p>
<div class="form-group m-0" ng-class="{'has-error': LoginForm.email.$invalid && LoginForm.email.$touched}">
<label class="form-label label-styling">Your Email</label>
<input type="email" placeholder="" class="form-control input-styling" ng-model="data.email" name="email" required pattern="[a-z0-9._%+-]+#[a-z0-9.-]+\.[a-z]{2,4}$">
<div class="error-state ">
<span class="error-label text-danger margin-styling" ng-show="LoginForm.email.$error.required && LoginForm.email.$touched">Email is Required</span>
<span class="error-label text-danger margin-styling" ng-show="LoginForm.email.$touched && LoginForm.email.$invalid && !LoginForm.email.$error.required">Invalid Email Address</span>
</div>
</div>
<div class="form-group m-0" ng-class="{'has-error': LoginForm.mobile.$invalid && LoginForm.mobile.$touched}">
<label class="form-label label-styling">Your Mobile</label>
<input type="text" placeholder="" class="form-control input-styling" ng-model="data.mobile" name="mobile" required pattern="^\d{4,12}$">
<div class="error-state ">
<span class="error-label text-danger margin-styling" ng-show="LoginForm.mobile.$error.required && LoginForm.mobile.$touched">Mobile Number is Required</span>
<span class="error-label text-danger margin-styling" ng-show="LoginForm.mobile.$touched && LoginForm.mobile.$invalid && !LoginForm.mobile.$error.required">Invalid Mobile Number</span>
</div>
</div>
<div class="form-group m-0" ng-class="{'has-error': LoginForm.name.$invalid && LoginForm.name.$touched}">
<label class="form-label label-styling">Your Name</label>
<input type="text" class="form-control input-styling" ng-model="data.name" name="name" placeholder="" required>
<div class="error-state ">
<span class="error-label text-danger margin-styling" ng-show="LoginForm.name.$error.required && LoginForm.name.$touched">Name is Required</span>
<!-- <span class="error-label text-danger margin-styling" ng-show="LoginForm.name.$touched && LoginForm.name.$invalid && !LoginForm.name.$error.required">Invalid Name</span> -->
</div>
</div>
<div class="form-group m-0">
<label class="form-label label-styling">What are you looking for?</label>
<select class="form-control input-styling" required name="spacetype" ng-change="changeSelected(workingSpace)" ng-model="workingSpace" ng-options="type as type.category for type in spaceTypes" ng-class="{'not-selected': !workingSpace}">
<option value="" disabled="">Select Type Of Space</option>
</select>
</div>
<div class="justify-content-center d-flex">
<button type="submit" class="btn-color fs-l-14 h5 btn-block btn-lg text-center rounded-0 margin-styling border-0" ng-disabled="sendingMail" ng-class="{'running': sendingMail}">
<span ng-hide="sendingMail">BOOK YOUR SPACE NOW</span>
<span ng-show="sendingMail">Submitting</span>
<div ng-show="sendingMail" class="ld ld-ring ld-spin"></div>
</button>
</div>
</fieldset>
</form>
</div>

I have created a form with angularjs validation but its not showing any errors

I am trying to create a form that changes tabs of login and signup that is working fine but the validations that i have used in the code are not working . I have created the controller but still the code is not working. Please have a look at the code and suggest the problem and solution for this problem.
<body ng-app="myApp" ng-controller="panelController as panel">
<div class="row no-gutters">
<div class="col">
<div class="container-fluid">
<nav class="navbar navbar-expand-lg">
<a class="navbar-brand mx-auto" href="#"><img class="brand-image"
src="images/recruitment.png">JobsFinder</a>
</nav>
<div class="logo-text">
<h3>The easiest way to get you new job</h3>
<p>We offer 12000 jobs vacation right now</p>
</div>
</div>
</div>
<div class="col">
<section>
<div class="form animated flipInX">
<ul class="tab-group">
<li class="tab" ng-class="{active: panel.isSelected(2)}"><a
href ng-click="panel.selectTab(2)">Log In</a></li>
<li class="tab" ng-class="{active: panel.isSelected(1)}"><a
href class="test" ng-click="panel.selectTab(1)">Sign Up</a></li>
</ul>
<div class="tab-content">
<div id="signup" ng-show="panel.isSelected(1)" >
<h3>Sign Up for Free</h3>
<form name="signupForm" class="signupForm" novalidate>
<div class="top-row">
<div class="field-wrap">
<input type="text" required autocomplete="off"
placeholder="First name" ng-model="fname">
<span style="color:red" ng-
show="signupForm.fname.$dirty && signupForm.fname.$invalid">
<span ng-
show="signupForm.fname.$error.required">First name is required.</span>
</span>
</div>
<div class="field-wrap">
<input type="text"required autocomplete="off"
placeholder="Last name" ng-model="lname">
<span style="color:red" ng-
show="signupForm.lname.$dirty && signupForm.lname.$invalid">
<span ng-
show="signupForm.lname.$error.required">Last name is required.</span>
</span>
</div>
</div>
<div class="field-wrap">
<input type="email" required autocomplete="off"
placeholder="Email" ng-model="signupemail">
<span style="color: indianred" ng-
show="signupForm.signupemail.$dirty && signupForm.email.$invalid">
<span ng-
show="signupForm.signupemail.$error.required">Email is required</span>
<span ng-
show="signupForm.signupemail.$error.email">Invalid email</span>
</span>
</div>
<div class="field-wrap">
<input type="password"required autocomplete="off"
placeholder="Password" ng-model="signpassword">
<span style="color: indianred" ng-
show="signupForm.signpassword.$dirty && signupForm.signpassword.$invalid">
<span ng-
show="signupForm.signpassword.$error.required">Password is required</span>
</span>
</div>
<div class="field-wrap">
<input type="password"required autocomplete="off"
placeholder="Confirm password" ng-model="cpass">
<span style="color: indianred" ng-
show="signupForm.cpass.$dirty && signupForm.cpass.$invalid">
<span ng-
show="signupForm.cpass.$error.required">Password is required</span>
</span>
</div>
<button type="submit" class="button button-block" ng-
click="submit()" ng-disabled="signupForm.signpassword.$dirty &&
signupForm.signpassword.$invalid || signupForm.signupemail.$dirty &&
signupForm.signupemail.$invalid || signupForm.cpass.$dirty &&
signupForm.cpass.$invalid"/>Get Started</button>
</form>
</div>
<div id="login" ng-show="panel.isSelected(2)" >
<h3>Welcome Back!</h3>
<form class="loginForm" name="loginForm" novalidate>
<div class="field-wrap">
<input type="email"required autocomplete="off"
placeholder="Email" ng-model="loginemail">
<span style="color: indianred" ng-
show="loginForm.loginemail.$dirty && loginForm.email.$invalid &&
loginForm.loginemail.$touched">
<span ng-
show="loginForm.loginemail.$error.required">Email is required</span>
<span ng-
show="loginForm.loginemail.$error.email">Invalid email</span>
</span>
</div>
<div class="field-wrap">
<input type="password"required autocomplete="off"
placeholder="Password" ng-model="logpassword">
<span style="color: indianred" ng-
show="loginForm.logpassword.$dirty && loginForm.logpassword.$invalid">
<span ng-
show="loginForm.logpassword.$error.required">Password is required</span>
</span>
</div>
<p class="forgot">Forgot Password?</p>
<button class="button button-block" type="submit" ng-
click="submit()" ng-disabled="loginForm.logpassword.$dirty &&
loginForm.logpassword.$invalid || loginForm.loginemail.$dirty &&
loginForm.loginemail.$invalid"/>Log In</button>
</form>
</div>
</div>
</div>
</section>
</div>
</div>
<footer>
<div class="text-center">
<p>Copyright © JobFinder 2017. Developed by Avneet Virk &
Shubham Dobriyal</p>
</div>
</footer>
<script src="https://unpkg.com/ionicons#4.2.2/dist/ionicons.js"></script>
<script src="js/panelController.js"></script>
</body>
You haven't specified any name for your inputs. So they're not correctly registered, underthat (absent) name in the form, so signupForm.fname (for example), is undefied.
Inputs must have a name:
<input name="fname" type="text" ... >

Not able to add validations to the elements in my form

I want to add validations to all the elements in the form. the error message should be displayed below the elements when the text of the control changes.
Following is my code:
<div role="tabpanel" class="tab-pane active" id="step-1">
<div class="col-md-4">
<div> <img src="../logo.jpg"
alt="Smiley face"
height="150"
style="margin:40px;"
width="150">
</div>
</div>
<div class="col-md-7">
<form action="r" name="regform"
method="post" >
<div class="col-md-6">
<div class="col-md-6" style="padding:0px;" >
<label for="mType" >Member Type*</label> <br />
<select id="member" ng-model="inputForm.mType" style="height:35px;width:135px;">
<option value="owner">Owner</option>
<option value="agent">Agent</option>
<option value="agent">Customer</option>
</select>
</div>
<div class="form-group">
<div class="col-md-6" style="padding:0px;" >
<label for="gender" >Gender </label> <br />
<select id="gender" ng-model="inputForm.gender" style="height:35px;width:135px;">
<option value="male">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select>
</div>
</div>
<div class="form-group">
<label for=''>First Name</label>
<input type='name'
name='fName'
ng-model="inputForm.fName"
ng-minlength="1"
ng-maxlength="25"
ng-pattern="/^[A-Za-z]+$/"
required
/>
<span ng-show="regform.fName.$error.pattern">Please enter valid number!</span>
<!-- <span ng-show="studentForm.firstName.$touched && studentForm.firstName.$error.required">First name is required.</span>
<span ng-show="studentForm.lastName.$touched && studentForm.lastName.$error.minlength">min 3 chars.</span>
<span ng-show="studentForm.lastName.$touched && studentForm.lastName.$error.maxlength">Max 10 chars.</span>-->
</div>
<div class="form-group">
<label>Last Name : </label>
<input type="text"
name="lName"
class="form-control input-lg"
placeholder="Last Name"
ng-model="inputForm.lName"
style="height:35px">
</input>
</div>
<div class="form-group">
<label for="DOB">Date of Birth :</label>
<input type="date"
id="dob"
class="form-control input-lg"
placeholder="Date Of Birth (mm/dd/yyyy)"
ng-model="inputForm.dob"
style="height:35px;">
</input>
</div>
<div class="form-group">
<label>Adhar Number:</label>
<input type="text" id="adhar"
class="form-control input-lg"
placeholder="Adhar Number"
ng-model="inputForm.adhar"
style="height:35px">
</input>
</div>
<div class="form-group">
<label>PAN Number :</label>
<input type="text" id="pan"
class="form-control input-lg"
placeholder="PAN Number"
ng-model="inputForm.pan"
style="height:35px">
</input>
</div>
<div class="form-group">
<label>Email Address :</label>
<input type="email" id="email"
class="form-control input-lg"
placeholder="Your Email"
ng-model="inputForm.email"
style="height:35px">
</input>
<!-- <span ng-show="studentForm.email.$touched && studentForm.email.$error.email">Please enter valid email id.</span>-->
</div>
</div>
<div class="col-md-5" >
<div class="full-width bg-transparent">
<div class="full-width">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="custom-form">
<div class="text-center bg-form">
<div class="img-section">
<img src="http://lorempixel.com/200/200/nature/"
class="imgCircle"
alt="Profile picture">
<span class="fake-icon-edit"
id="PicUpload"
style="color: #ffffff;">
<span class="glyphicon glyphicon-camera camera"></span>
</span>
<div class="col-lg-12">
<h4 class="text-right col-lg-12" style="color:balck;">
<span class="glyphicon glyphicon-edit"></span> Edit Profile
</h4>
<input type="checkbox" class="form-control" id="checker"></input>
</div>
</div>
<input type="file"
id="image-input"
onchange="readURL(this);"
accept="image/*"
disabled class="form-control form-input Profile-input-file" >
</input>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-8" >
<hr class="colorgraph" style="height: 5px;
border-top: 0;
background: #62c2e4;
border-radius: 5px;">
<div class="col-xs-4 col-xs-offset-3">
<a ui-sref="form.account" class="btn btn-lg btn-primary btn-block signup-btn"
style=" height:35px;
margin-bottom:10px;
padding:0px;" >
Next <span class="glyphicon glyphicon-circle-arrow-right"></span>
</a>
</div>
</div>
</form>
</div>
</div>
image for reference
Please give suggestions to change the code so that appropriate error messages will be displayed to the controls after validating the input entr the user.
Your question is a bit vague as we can do what you are asking in many ways but find below an example using Bootstrap :
<form name="search" class="form-horizontal">
<div class="form-group col-md-2 required" ng-class="{
'has-feedback': (search.$submitted && search.carrier.$invalid),
'has-error': (search.$submitted && search.carrier.$invalid)}">
<label class="control-label" for="carrier">Carrier Code:</label>
<input type="text" class="form-control"
id="carrier" name="carrier"
required
pattern="[a-zA-Z0-9-]{2,3}"
maxlength="3"
ng-model="myAngularCtrl.flightDetails.carrier"/>
<span ng-show="search.$submitted && search.carrier.$error.required" class="field_errormsg-below">The Carrier Code is Mandatory</span>
<span ng-show="search.$submitted && search.carrier.$error.pattern" class="field_errormsg-below">use only numbers, digit and -</span>
</div>
<button type="submit"
class="btn btn-default FHU_margin-top-20"
ng-click="myAngularCtrl.searchFlight(search)">
Submit
</button>
</form>
You have a few things here:
The form has a name: search
You see two kind of error message being displayed. For them to be displayed, the user needs to have tried to submit the form (search.$submitted) and the field carrier needs to be in error (search.carrier.$error.required or search.carrier.$error.pattern)

In console error showing ignore attempt to cancel a touchend

I design on form for user registration in ionic app, run in debug mode on phone and fill form and when I'm submitting form application not responding anything else and when I'm checking it on console error is showing like
"Ignored attempt to cancel a touchend event with cancelable=false, for
example because scrolling is in progress and cannot be interrupted."
<ion-view view-title="Sign Up" class="login-main">
<ion-header-bar>
<h1 class="title">Sign Up</h1>
</ion-header-bar>
<ion-content>
<div class="row">
<div class="login-both-fields">
<div class="list">
<form class="padding" id="signup-form" ng-submit="signup(signupForm.$valid)" name="signupForm" novalidate>
<label class="item item-input">
<span class="input-label login-input-icon"><i class="ion-person"></i></span>
<input type="text" placeholder="Name*" name="m_name" ng-model="mSignupData.m_name" required>
<span ng-show="submitted && signupForm.m_name.$error.required" class="popup-validation-signup">
Please enter name
</span>
</label>
<label class="item item-input">
<span class="input-label login-input-icon"><i class="ion-person"></i></span>
<input type="text" placeholder="Surename*" name="m_surename" ng-model="mSignupData.m_surename" required>
<span ng-show="submitted && signupForm.m_surename.$error.required" class="popup-validation-signup">
Please enter surename
</span>
</label>
<label class="item item-input">
<span class="input-label login-input-icon"><i class="ion-ios-location"></i></span>
<input type="text" placeholder="Address*" name="m_address" ng-model="mSignupData.m_address" required>
<span ng-show="submitted && signupForm.m_address.$error.required" class="popup-validation-signup">Please enter address</span>
</label>
<label class="item item-input">
<span class="input-label login-input-icon"><i class="ion-calendar"></i></span>
<input type="date" placeholder="Date Of Birth*" name="m_dob" ng-model="mSignupData.m_dob" required>
<span ng-show="submitted && signupForm.m_dob.$error.required" class="popup-validation-signup">Please enter DOB</span>
</label>
<label class="item item-input">
<span class="input-label login-input-icon"><i class="ion-iphone"></i></span>
<input type="number" placeholder="Mobile Number" name="m_mobno" ng-model="mSignupData.m_mobno" required>
<span ng-show="submitted && signupForm.m_mobno.$error.required" class="popup-validation-signup">Please enter mobile no</span>
</label>
<label class="item item-input">
<span class="input-label login-input-icon"><i class="ion-ios-email"></i></span>
<input type="email" placeholder="Email*" name="m_email" ng-model="mSignupData.m_email" required>
<span ng-show="submitted && signupForm.m_email.$error.required" class="popup-validation-signup">Please enter emailid</span>
<span ng-show="submitted && signupForm.m_email.$error.email" class="popup-validation-signup">Please enter valid emailid</span>
</label>
<label class="item item-input">
<span class="input-label login-input-icon"><i class="ion-person"></i></span>
<input type="text" placeholder="User Name*" name="m_username" ng-model="mSignupData.m_username" required>
<span ng-show="submitted && signupForm.m_username.$error.required" class="popup-validation-signup">Please enter username</span>
</label>
<label class="item item-input">
<span class="input-label login-input-icon"><i class="ion-locked"></i></span>
<input type="password" placeholder="Password*" name="m_pwd" ng-model="mSignupData.m_pwd" ng-minlength="8" required>
<span ng-show="submitted && signupForm.m_pwd.$error.required" class="popup-validation-signup">Please enter password</span>
<span ng-show="submitted && loginForm.m_pwd.$error.minlength" class="validation-login popup-forvalidation correct-password-login-error">Password should be min 8 character.</span>
</label>
<div class="term-line-signup">
<input id="terms" type="checkbox" name="vehicle" value="Bike" ng-model="mSignupData.vehicle" required> <label for="terms" class="lable-readinfo">By Accept</label> terms& conditions.
<span ng-show="submitted && signupForm.vehicle.$error.required" class="popup-validation-signup please-confirm-condtion">Please accept terms&condition</span>
</div>
<button type="submit" ng-click="submitted = true" class="button button-block button-positive button-energized client-btn">Register</button>
<a class="button button-block button-positive Normal-btn" href="#/mLogin">Signin</a>
</form>
</div>
</div>
</div>
</ion-content>
</ion-view>
You can try return true from touchend and everything will work fine.
Do like this :
var scroll=false;
//while moving
$("body").on("touchmove", function(){
scroll = true;
});
//at the end of touch
$("body").on("touchend", function(){
if (scroll)
return;
// wasn't a drag, just a tap
// more code here
});
//when touch starts
$("body").on("touchstart", function(){
scroll = false;
});

How do i check if an email address exists when user signup (Angularjs and Firebase)

I am currently working on a project thats using firebase and angularjs and i want my application to check if an email already exists everytime a user try to create an account.
here is HTML markup:
<div class="well text-center">
<h1 class="text-info"><i class="fa fa-group socio_icon"></i></h1>
<h1>Blog title</h1>
<p class="lead">Slogan goes here</p>
<form name="signup_form" novalidate autocomplete="off">
<p>
<div class="input-group input-group-lg" ng-class="{'has-error': signup_form.fullnames.$dirty && signup_form.fullnames.$invalid , 'has-success': signup_form.fullnames.$valid}">
<span class="input-group-addon"><i class="fa fa-user"></i></span>
<input type="text" class="form-control" placeholder="Enter full names" name="fullnames" ng-model="signup.form" ng-minlength=5 ng-maxlength=45 required />
<span class="input-group-addon valid" ng-show="signup_form.fullnames.$dirty && signup_form.fullnames.$valid"><i class="fa fa-check-circle text-success"></i></span>
<span class="input-group-addon valid" ng-show="signup_form.fullnames.$dirty && signup_form.fullnames.$invalid"><i class="fa fa-exclamation-circle text-warning"></i></span>
</div>
</p>
<p>
<div class="input-group input-group-lg" ng-class="{'has-error': signup_form.email.$dirty && signup_form.email.$invalid , 'has-success': signup_form.email.$valid}">
<span class="input-group-addon"><i class="fa fa-envelope-o"></i></span>
<input type="email" class="form-control" placeholder="Enter email address" name="email" ng-model="signup.email" ng-minlength=5 ng-maxlength=45 required />
<span class="input-group-addon valid" ng-show="signup_form.email.$dirty && signup_form.email.$valid"><i class="fa fa-check-circle text-success"></i></span>
<span class="input-group-addon valid" ng-show="signup_form.email.$dirty && signup_form.email.$invalid"><i class="fa fa-exclamation-circle text-warning"></i></span>
</p>
<p>
<div class="input-group input-group-lg" ng-class="{'has-error': signup_form.password1.$dirty && signup_form.password1.$invalid , 'has-success': signup_form.password1.$valid}">
<span class="input-group-addon"><i class="fa fa-lock"></i></i></span>
<input type="password" class="form-control" placeholder="Enter password" name="password1" ng-model="password1" ng-pattern="/(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z])/" ng-minlength=6 ng-maxlength=45 required />
<span class="input-group-addon valid" ng-show="signup_form.password1.$dirty && signup_form.password1.$valid"><i class="fa fa-check-circle text-success"></i></span>
<span class="input-group-addon valid" ng-show="signup_form.password1.$dirty && signup_form.password1.$invalid"><i class="fa fa-exclamation-circle text-warning"></i></span>
</div>
</p>
<p>
<div class="input-group input-group-lg" ng-class="{'has-error': signup_form.password2.$dirty && signup_form.password2.$invalid , 'has-success': signup_form.password2.$valid}">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
<input type="password" class="form-control" id="password2" name="password2" ng-model="password2" ng-minlength="8" ng-maxlength="20" ng-pattern="/(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z])/" required placeholder="Re-enter password"/>
<span class="input-group-addon valid" ng-show="signup_form.password2.$dirty && signup_form.password2.$valid"><i class="fa fa-check-circle text-success"></i></span>
<span class="input-group-addon valid" ng-show="signup_form.password2.$dirty && signup_form.password2.$invalid"><i class="fa fa-exclamation-circle text-warning"></i></span>
</div>
</p>
<p>
<button type="submit" ng-disabled="signup_form.$invalid" class="btn btn-primary btn-lg btn-block">Singup and enjoy!
</button>
</p>
</form>
</div>
and the js looks like this:
'use strict';
angular.module('myApp')
.controller('MainCtrl', function ($scope) {
var ref = new Firebase('https://myfirebase.firebaseio.com/');
});
The typical method for checking existence of records in Firebase is to use an index. Since firebase does not certain characters in references, you will need to escape the email first.
Since this is a common question I have a gist showing how to do this.
The "gist", to forgive a pun, is that you need to create an index whenever you create users, and then check that index:
var fb = new Firebase(URL);
function isDuplicateEmail(email, callback) {
fb.child('email_index/'+escapeEmail(email)).once('value', function(snap) {
callback( snap.val() !== null );
});
}
function updateUser(user_id, email) {
fb.child('user/'+user_id).set({email: email});
fb.child('email_index/'+escapeEmail(email)).set(user_id);
}
function escapeEmail(email) {
return (email || '').replace('.', ',');
}

Resources