Can you use an Ember.computed.alias inside a Component?


#1

I am subclassing DS.Adapter and impliment the base CRUD functions like, find, findAll, create, delete, update.

Spark.SubmitFormComponent = Ember.Component.extend({
  needs: "gameList",
  fields: Ember.computed.alias("controllers.gameList.fields"),

	printFields: function() {
		console.log("Printing Fields in Component");
		console.log(this.get("fields"))
	}.property()
});

Spark.GameController = Spark.EntityController.extend({
  needs: "gameList",
  fields: Ember.computed.alias("controllers.gameList.fields"),

  	printFields: function() {
		console.log("Printing Fields in Controller");
		console.log(this.get("fields"));
	}.property()
});

In one the controller I get the field fine but in the component it’s undefined. Note that that component is used inside that controller.


#2

You can’t specify needs in a component, as components are by-design isolated and shouldn’t know about the “outside world” directly. Anything your component needs access to, you must pass in explicitly:

{{my-component fieldsForComponent=fieldsFromController}}