denniss
denniss

Reputation: 17589

What is the difference between 'model.property' vs 'property' for computed property?

Going throught the getting started tutorial for ember js and I am somewhat confused by what the differences are in doing

function(){}.property('model.isCompleted')

and

function(){}.property('isCompleted')

Specifically, what is the model for?

Upvotes: 0

Views: 77

Answers (1)

givanse
givanse

Reputation: 14943

The model is just another property, but instead of being a primitive such as a string or a number its an object.

For:

model = {
  prop1: 'fi',
  prop2: 'fai',
  prop3: 'fo',
  prop4: 'fu'
}

If you do this: function(){}.property('model.prop3') your computed property will be updated only when prop3 changes.

If you do this: function(){}.property('model') your computed property will be updated when model changes.

And model is a property in your controller set by the route you are in.

Upvotes: 1

Related Questions