当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ember.Route类代码示例

本文整理汇总了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',
        });
开发者ID:worr,项目名称:DefinitelyTyped,代码行数:31,代码来源:route.ts

示例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);
    }
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:31,代码来源:injections.ts

示例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'
    });
  }
});
开发者ID:NullVoxPopuli,项目名称:aeonvera-ui,代码行数:13,代码来源:route.ts

示例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);
  }
});
开发者ID:NullVoxPopuli,项目名称:aeonvera-ui,代码行数:28,代码来源:route.ts

示例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);
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:31,代码来源:mixin.ts

示例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
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:31,代码来源:error.ts

示例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');
            }
        }
    }
});
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:28,代码来源:transition.ts

示例8: model

import Ember from 'ember';

export default Ember.Route.extend({
  model() {
    return this.modelFor('event-at-the-door');
  }
});
开发者ID:NullVoxPopuli,项目名称:aeonvera-ui,代码行数:7,代码来源:route.ts


注:本文中的ember.Route类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。