Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to use the rating directive of bootstrap module for angular but when I click on a star to rate then angular trig this error

enter link description here

I understand that this error is produced because the value that I use in the model it's a constnatn. Let me explain

I have this directive in nrate.html

<rating ng-model="rate" max="5" readonly="false" value="2"></rating>

and this controller

appControllers.controller("singleRatingController", function ($scope, $http) {
    $scope.rate = 0;
});

so I'm using a variable "rate" to load the rate value

In other html page I use the same directive with the same controller and works well

thanks

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Use either value or ng-model, not both, depending on which UI Bootstrap version you are using.

JS for both cases:

appControllers.controller("singleRatingController", function ($scope, $http) {
  $scope.rate = 2;
});

HTML - If using 0.11.0:

<rating ng-model="rate" max="5" readonly="false"></rating>

HTML - If using 0.10.0 or below:

<rating value="rate" max="5" readonly="false"></rating>
share|improve this answer
    
Certainly the problem was caused because i used the 0.9.0 vesrion and use ng-model directive. Using value instead of ng-model solve the problem. Thanks –  user2482648 4 hours ago
    
You're welcome :) –  tasseKATT 4 hours ago
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.