|
| 1 | +import { alias, sum as add } from "@ember/object/computed"; |
| 2 | +import { get, set, observer, computed } from "@ember/object"; |
| 3 | +import { inject as controller } from "@ember/controller"; |
| 4 | +import { inject as service } from "@ember/service"; |
| 5 | +import { on } from "@ember/object/evented"; |
| 6 | +import layout from "components/templates/foo"; |
| 7 | + |
| 8 | +const Foo = EmberObject.extend({ |
| 9 | + tagName: "div", |
| 10 | + classNames: ["test-class", "custom-class"], |
| 11 | + a: "", |
| 12 | + b: service("store"), |
| 13 | + myController: controller("abc"), |
| 14 | + observedProp: observer("xyz"), |
| 15 | + event: on("click"), |
| 16 | + |
| 17 | + actions: { |
| 18 | + /** |
| 19 | + Comments |
| 20 | + */ |
| 21 | + bar(temp1) {}, |
| 22 | + baz() { |
| 23 | + this._super(...arguments); |
| 24 | + }, |
| 25 | + biz() {} |
| 26 | + } |
| 27 | +}); |
| 28 | + |
| 29 | +var comp = EmberObject.extend({ |
| 30 | + classNameBindings: ["isEnabled:enabled:disabled", "a:b:c", "c:d"], |
| 31 | + isEnabled: false, |
| 32 | + a: true, |
| 33 | + c: "", |
| 34 | + attributeBindings: ["customHref:href"], |
| 35 | + |
| 36 | + customHref: "http://emberjs.com" |
| 37 | +}); |
| 38 | + |
| 39 | +const Foo = EmberObject.extend({ |
| 40 | + firstName: null, |
| 41 | + lastName: null, |
| 42 | + |
| 43 | + /** |
| 44 | + Computed fullname |
| 45 | + */ |
| 46 | + fullName: computed("firstName", "lastName", { |
| 47 | + get(key) { |
| 48 | + return `${this.get("firstName")} ${this.get("lastName")}`; |
| 49 | + }, |
| 50 | + set(key, value) { |
| 51 | + let [firstName, lastName] = value.split(/\s+/); |
| 52 | + this.set("firstName", firstName); |
| 53 | + this.set("lastName", lastName); |
| 54 | + return value; |
| 55 | + } |
| 56 | + }), |
| 57 | + |
| 58 | + /** |
| 59 | + Computed description |
| 60 | + */ |
| 61 | + description: computed("fullName", "age", "country", function() { |
| 62 | + return `${this.get( |
| 63 | + "fullName" |
| 64 | + )}; Age: ${this.get("age")}; Country: ${this.get("country")}`; |
| 65 | + }), |
| 66 | + |
| 67 | + /** |
| 68 | + * Fname |
| 69 | + */ |
| 70 | + fName: alias("firstName"), |
| 71 | + |
| 72 | + /** |
| 73 | + * Lname |
| 74 | + */ |
| 75 | + lName: alias("firstName", "lastName").readOnly(), |
| 76 | + |
| 77 | + /** |
| 78 | + * Lname1 |
| 79 | + */ |
| 80 | + lName1: add("description", "lastName").volatile() |
| 81 | +}); |
| 82 | + |
| 83 | +const Foo = EmberObject.extend({ |
| 84 | + layout |
| 85 | +}); |
0 commit comments