我已经构建了一个ember前端应用程序,该应用程序使用在另一个应用程序中使用rails制作的API。 ember应用程序成功地从rails api请求和接收数据,我的一个把手模板(显示我毕业生模型中所有毕业生的列表的索引页)工作正常。然而,用于显示个别毕业生的页面无法呈现有关这些个别毕业生的数据。虽然当我在浏览器(Chrome)中的开发者控制台中打开ember工具时,该数据仍然存在。
我刚刚接受了这个问题,而且我已经试图解决这个问题2天了,但我完全被难过了,任何帮助都会非常感激!
app / adapters / application.js:
import DS from 'ember-data';
export default DS.ActiveModelAdapter.extend({
namespace: 'api/v1',
host: 'http://localhost:3000'
});
应用程序/模型/ graduate.js:
import DS from 'ember-data';
export default DS.Model.extend({
firstName: DS.attr('string'),
lastName: DS.attr('string'),
cohort: DS.attr('string'),
currentJob: DS.attr('string'),
bio: DS.attr('string'),
news: DS.attr('string'),
website: DS.attr('string'),
picture: DS.attr('string'),
createdAt: DS.attr('date'),
updatedAt: DS.attr('date')
});
路由/毕业生/ index.js:
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.store.find('graduate');
}
});
路由/ graduate.js:
import Ember from 'ember';
export default Ember.Route.extend({
model: function(params) {
return this.store.find('graduate', params.graduate_id);
}
});
app / router.js:
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
export default Router.map(function() {
this.resource('graduates', function() {
this.resource('graduate', { path: '/:graduate_id' });
});
});
environment.js:
/* jshint node: true */
module.exports = function(environment) {
var ENV = {
contentSecurityPolicy: {
'connect-src': "'self' http://localhost:3000",
'default-src': "'none' http://localhost:3000",
'script-src': "'self'",
'font-src': "'self' http://localhost:3000",
'img-src': "'self' http://localhost:3000",
'style-src': "'self' http://localhost:3000 'unsafe-inline",
'media-src': "'self' http://localhost:3000"
},
modulePrefix: 'flatbook-front',
environment: environment,
baseURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary
build
// e.g. 'with-controller': true
}
},
APP: {
// Here you can pass flags/options to your application instance
// when it is created
}
};
if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true;
// ENV.APP.LOG_ACTIVE_GENERATION = true;
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true;
}
if (environment === 'test') {
// Testem prefers this...
ENV.baseURL = '/';
ENV.locationType = 'none';
// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
}
if (environment === 'production') {
}
return ENV;
};
app / templates / graduate.hbs:
<h1>{{firstName}} {{lastName}}</h1>
答案 0 :(得分:0)
应该是
<form name="form" novalidate form-validate method="POST" action="https://sis-t.redsys.es:25443/sis/realizarPago">
<input name="alias" ng-change="updateData(alias)" ng-model="alias" type="text" class="form-control validate" placeholder="{{ translates.alias_desc }}" required>
<button type="submit">Submit</button>
</form>
您的模板
// app/templates/graduate.hbs
<h1>{{model.firstName}} {{model.lastName}}</h1>
显示当前控制器(类Ember.Controller)的<h1>{{firstName}} {{lastName}}</h1>
和firstName
属性,但它们未设置。
请在此处查看问题的历史记录:http://emberjs.com/deprecations/v1.x/#toc_objectcontroller。