I am trying to validate an email
address and accordingly enable or disable the action button. but it's not work. i am very new to emberjs
any one please help me here? Here is my Tutorial
html code ( hbs ) :
<div class="jumbotron text-center">
<h1>Coming Soon</h1>
<br/><br/>
<p>Don't miss our launch date, request an invitation now.</p>
<div class="form-horizontal form-group form-group-lg row">
<div class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-1 col-md-5 col-md-offset-2">
<input type="email" value=emailAddress class="form-control" placeholder="Please type your e-mail address." autofocus="autofocus"/>
</div>
<div class="col-xs-10 col-xs-offset-1 col-sm-offset-0 col-sm-4 col-md-3">
<button class="btn btn-primary btn-lg btn-block" disabled= >Request invitation</button>
</div>
</div>
<br/><br/>
</div>
controller js :
import Ember from 'ember';
export default Ember.Controller.extend({
emailAddress:'',
isValid: Ember.computed.match('emailAddress', /^.+@.+\..+$/),
isDisabled: Ember.computed.not('isValid'),
actualEmailAddress: Ember.computed('emailAddress', function() {
console.log('actualEmailAddress function is called: ', this.get('emailAddress'));
}),
emailAddressChanged: Ember.observer('emailAddress', function() {
console.log('observer is called', this.get('emailAddress'));
}),
actions: {
saveInvitation() {
alert(`Saving of the following email address is in progress: ${this.get('emailAddress')}`);
this.set('responseMessage', `Thank you! We've just saved your email address: ${this.get('emailAddress')}`);
this.set('emailAddress', '');
}
}
});
when i enter the valid email, button not enables!! Thanks in advance.
UPDATE:
In browser I am getting this error :
DEPRECATION: Usage of `router` is deprecated, use `_routerMicrolib` instead.
Aucun commentaire:
Enregistrer un commentaire