But whenever I try to set a value in the second dropdown I get the following error:
Attempted to assign to readonly property.
My markup looks like this
<div ng-controller="Rating">
<select ng-model="model.value" name="rating" id="rating" ng-options="c.id as c.value for c in ratings"></select> of
<select ng-model="model.value.limit" name="rating-limit" id="rating-limit" ng-options="c.id as c.value for c in ratings"></select>
</div>
<div ng-controller="Rating">
<select ng-model="ratingValue" name="rating" id="rating" ng-options="c.id as c.value for c in ratings" ng-change="saveRating()"></select> of
<select ng-model="limitValue" name="rating-limit" id="rating-limit" ng-options="c.id as c.value for c in ratings" ng-change="saveLimit()"></select>
</div>
One custom property, but with 2 fields
I'm trying to do something like this:
But whenever I try to set a value in the second dropdown I get the following error:
My markup looks like this
What is it I'm doing wrong ?
Hi Sebastian
Do you mind sharing the controller as well? Is it an error shown in the console log?
/Jan
Here is the controller
Yes, the error appears in the console log.
Hi Sebastian
Ok, I think it's because you're trying to use $scope.model.value.limit - Limit does not exists and needs to be declared in the controller I think.
You should probably consider storing the values as an object in $scope.model.value like $scope.model.value = {rating:null, limit:null}
What is the purpose of your property editor? What is the purpose of the limit?
/Jan
This is the idea. Let's say you have a website with products that gets reviewed atround the web.
You never know what the scale goes to, so this part has to flexible
Hmmm ... it doesn't save.
You can see the entire property here:
https://gist.github.com/f74ea70100241f9eb16f
Hi Sebastian
You'll need to set it like $scope.model.value = {rating:null. limit:null}
So for instance your controller can look like this
Then your view could look like this
Hope this helps and makes sense.
/Jan
Absolutely .. it works like a charm.
This is what I ended up with:
https://gist.github.com/f74ea70100241f9eb16f
Hi Sebastian
Happy that I could help - Ehm, but the second links seems to be to the same code that you initially had issues with? :)
/Jan
Yeah, almost.
The binding is different
ng-model="model.value.rating" / ng-model="model.rating.value"
Hi Sebastian
Aaah yes of course - I'm going blind :)
/Jan
is working on a reply...