當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ember.Controller類代碼示例

本文整理匯總了TypeScript中ember.Controller的典型用法代碼示例。如果您正苦於以下問題:TypeScript Controller類的具體用法?TypeScript Controller怎麽用?TypeScript Controller使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Controller類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: model

import Ember from 'ember';
import DS from 'ember-data';

Ember.Route.extend({
    model(): any {
        return this.store.findAll('my-model');
    }
});

Ember.Controller.extend({
    actions: {
        create(): any {
            return this.store.createRecord('my-model');
        }
    }
});

Ember.DataAdapter.extend({
    test() {
        this.store.findRecord('my-model', 123);
    }
});
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:22,代碼來源:injections.ts

示例2:

import Ember from 'ember';

export default Ember.Controller.extend({
  // Just a very roundabout way of using some ES6 features
  value: ((test = 'Test') => `${test} ${'Value'}`)()
});
開發者ID:Diamond,項目名稱:ember-cli-typescript-compiler,代碼行數:6,代碼來源:application.ts

示例3: 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


注:本文中的ember.Controller類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。