-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
Copy pathcontroller.js
60 lines (49 loc) · 1.48 KB
/
controller.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { assert } from 'ember-debug';
import EmberObject from '../system/object';
import Mixin from '../mixins/controller';
import { createInjectionHelper } from '../inject';
import { deprecateUnderscoreActions } from '../mixins/action_handler';
/**
@module @ember/controller
*/
/**
@class Controller
@extends EmberObject
@uses Ember.ControllerMixin
@public
*/
const Controller = EmberObject.extend(Mixin);
deprecateUnderscoreActions(Controller);
function controllerInjectionHelper(factory) {
assert(
'Defining an injected controller property on a ' +
'non-controller is not allowed.',
Mixin.detect(factory.PrototypeMixin)
);
}
/**
Creates a property that lazily looks up another controller in the container.
Can only be used when defining another controller.
Example:
```app/controllers/post.js
import Controller, {
inject as controller
} from '@ember/controller';
export default Controller.extend({
posts: controller()
});
```
This example will create a `posts` property on the `post` controller that
looks up the `posts` controller in the container, making it easy to
reference other controllers.
@method inject
@static
@for @ember/controller
@since 1.10.0
@param {String} name (optional) name of the controller to inject, defaults
to the property's name
@return {Ember.InjectedProperty} injection descriptor instance
@public
*/
createInjectionHelper('controller', controllerInjectionHelper);
export default Controller;