Reputation: 2008
This is the example jsfiddle. I'm trying to ng-model
the value on click of some thing. but this value is not updating in directive
.I tried with $scope.$watch
also . I'm sorry for poor english and newbie to angularjs
.
<div ng-click=show()>show directive</div>
<div ng-show="afterSomeTime">
<div class="star-rating" star-rating rating-value="rating"
data-max="10" on-rating-selected="rateFunction(rating)"></div>sdsadasdasd</div>
here i was trying to trigger directive after some click event but i was not able to achieve.check out that example js fiddle link
Upvotes: 0
Views: 265
Reputation: 26
You have to define $scope.rating first with some initial value, then only you can bind that with directive.
code https://jsfiddle.net/nbakliwal18/aL7cs9je/1/
Upvotes: 1
Reputation: 139
Start from line 43
scope.$watch('ratingValue',
function(oldVal, newVal) { //<-this is where you did wrong
if (newVal) {
updateStars();
}
}
);
Just swap oldVal
and newVal
, you should now make it work I believe.
Upvotes: 1