本文整理汇总了TypeScript中ember.Route类的典型用法代码示例。如果您正苦于以下问题:TypeScript Route类的具体用法?TypeScript Route怎么用?TypeScript Route使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Route类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: hideModal
outlet: 'modal',
into: 'application',
});
},
hideModal(evt: { modalName: string }) {
this.disconnectOutlet({
outlet: 'modal',
parentView: 'application',
});
},
},
});
Ember.Route.extend({
model() {
return this.modelFor('post');
},
});
Route.extend({
queryParams: {
memberQp: { refreshModel: true },
},
});
Route.extend({
renderTemplate() {
this.render('photos', {
into: 'application',
outlet: 'anOutletName',
});
示例2: model
import Ember from 'ember';
import DS from 'ember-data';
import Controller from '@ember/controller';
class MyModel extends DS.Model {}
declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'my-model': MyModel;
}
}
Ember.Route.extend({
model(): any {
return this.store.findAll('my-model');
}
});
Controller.extend({
actions: {
create(): any {
this.queryParams;
return this.store.createRecord('my-model');
}
}
});
Ember.DataAdapter.extend({
test() {
this.store.findRecord('my-model', 123);
}
示例3: model
import Ember from 'ember';
export default Ember.Route.extend({
model(params, transition) {
const id = params.shirt_id;
const event = this.modelFor('events.show');
return this.store.findRecord('shirt', id, {
event_id: event.get('id'),
include: 'order_line_items.order.registration'
});
}
});
示例4: model
import Ember from 'ember';
import RSVP from 'rsvp';
import { UNREGISTERED_ID } from 'aeonvera/models/registration';
const { isBlank } = Ember;
export default Ember.Route.extend({
model() {
return this.modelFor('register.event-registration.show');
},
setupController(controller: Ember.Controller, model: any) {
const registration = model.registration;
const shouldClear = registration.get('isNew') && controller.get('registration');
if (shouldClear) {
controller.set('order', null);
if (controller.get('registration')) {
controller.set('registration', null);
controller.set('model', null);
}
}
this._super(controller, model);
}
});
示例5: edit
const EditableMixin = Ember.Mixin.create<EditableMixin, Ember.Route>({
edit() {
this.get('controller');
console.log('starting to edit');
this.set('isEditing', true);
},
isEditing: false
});
const EditableComment = Ember.Route.extend(EditableMixin, {
postId: 0,
canEdit() {
return !this.isEditing;
},
tryEdit() {
if (this.canEdit()) {
this.edit();
}
}
});
const comment = EditableComment.create({
postId: 42
});
comment.edit();
comment.canEdit();
comment.tryEdit();
assertType<boolean>(comment.isEditing);
示例6: error
},
{
detail: 'Must not be blank',
source: { pointer: '/data/attributes/content' },
},
]);
// https://emberjs.com/api/ember-data/2.16/classes/DS.TimeoutError
const { TimeoutError } = DS;
const timedOut = Ember.Route.extend({
actions: {
error(error: any, transition: any) {
if (error instanceof TimeoutError) {
// alert the user
alert('Are you still connected to the internet?');
return;
}
// ...other error handling logic
},
},
});
// This is technically private, but publicly exposed for APIs to use. We just
// check that it is a proper subclass of `AdapterError`.
// https://emberjs.com/api/ember-data/2.16/classes/DS.AbortError
// https://github.com/emberjs/data/blob/v2.16.0/addon/-private/adapters/errors.js#L206-L216
const { AbortError } = DS;
assertType<typeof AdapterError>(AbortError);
// https://emberjs.com/api/ember-data/2.16/classes/DS.UnauthorizedError
示例7: beforeModel
import Ember from 'ember';
Ember.Route.extend({
beforeModel(transition: Ember.Transition) {
if (new Date() > new Date('January 1, 1980')) {
alert('Sorry, you need a time machine to enter this route.');
transition.abort();
}
}
});
Ember.Controller.extend({
previousTransition: null as Ember.Transition | null,
actions: {
login() {
// Log the user in, then reattempt previous transition if it exists.
let previousTransition = this.get('previousTransition');
if (previousTransition) {
this.set('previousTransition', null);
previousTransition.retry();
} else {
// Default back to homepage
this.transitionToRoute('index');
}
}
}
});
示例8: model
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.modelFor('event-at-the-door');
}
});