控制器/新客户
actions: {
addInfo: function() {
var name = this.get('name');
var e_mail = this.get('e-address');
var emoney = this.get('e-money');
var newCustomer = this.store.createRecord('customers', {
name : name,
email : e_mail,
emoney : emoney
});
newCustomer.save();
alert("You\'re added");
}
模型/customers.js
import DS from 'ember-data';
export default DS.Model.extend({
name:DS.attr('string'),
email:DS.attr('string'),
emoney:DS.attr('number'),
rev: attr('string')
});
模板/新客户.hbs
<form class="form-horizontal">
<div class="form-group control-group error">
<label class="control-label" for="inputError">Name</label>
{{input type="text" class="form-control" value=name placeholder = "Enter your name" size="15"}}
</div>
<div class="form-group">
<label>Email Address</label>
{{textarea type="text" class="form-control" value=e-address placeholder = "Enter your Email Address"}}
</div>
<div class="form-group">
<label>E-Money</label>
{{input type="number" class="form-control" value=e-money}}
</div>
<button {{action 'addInfo'}}type="button" class="btn btn-primary">Submit !!</button>
</form>
我错过了什么吗?单击提交按钮时我在控制台上出现的错误是:
加载资源失败:服务器响应状态为 404(未找到)vendor.js:27458 Ember 数据请求 POST /customers 返回 404 Payload (text/html; charset=utf-8) Cannot POST /customers
在ajaxError ( http : _ //localhost:4200/assets/vendor.js:85736:25 ) 在 Class.hash.error ( http://localhost:4200/assets/vendor.js:85310:23 ) 在火 ( http://localhost: 4200/assets/vendor.js:3637:31 ) 在 Object.fireWith [as rejectWith] ( http://localhost:4200/assets/vendor.js:3767:7 ) 在完成 ( http://localhost:4200/ assets/vendor.js:9576:14)在 XMLHttpRequest。( http://localhost:4200/assets/vendor.js:9816:9 ) defaultDispatch@vendor.js:27458