When I load my pages for my forms, I get null/undefined datasets before I even enter any information into the form. I'm using ember g http-mock to generate an API.
models/signup import DS from 'ember-data';
export default DS.Model.extend({
firstName: DS.attr(),
lastName: DS.attr(),
username: DS.attr(),
email: DS.attr(),
password: DS.attr(),
confirmPassword: DS.attr()
});
app/components/signup-form
import Ember from 'ember';
import zxcvbn from 'npm:zxcvbn';
const {
Component, String: { w }, isEmpty, set
} = Ember;
saved: false,
classNames: ['container', 'form'], //creates the class
rules: {
sharedValidations: {
required: w('email firstName lastName userName confirmPassword')
//this is ember shorthand to require these fields... see the const to
understand the 'w' better
},
email: 'email',
password: {
required: true,
between: [4,16],
password(value) {
if(isEmpty(value)) return "can't be blank";
const { score } = zxcvbn(value);
if (score < 3) return 'too weak';
}
},
actions: {
submit() {
set(this, 'saved', true);
}
}
});
models/signup.js
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.get('store').createRecord('signup');
}
});
app/adapters/application.js
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
namespace: 'api',
});
Not sure if this is a server issue or if I need to create some controllers... Ember is a new coding language for me. If you require more information please let me know.
Aucun commentaire:
Enregistrer un commentaire