本文整理匯總了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');
}
});