I'm new to angualarjs and just start to build a page using angularjs 1.5 component. I'm trying to understand the following example from pluralsight. Does angularjs extended javascript with partial application/currying and others?
movie-rating.component.html:
function model.setRating() is passed with an object with property of value.
<span ng-repeat="entry in model.entries track by $index">
<span ng-click="model.setRating({ value: $index + 1})" class="glyphicon {{entry}}">
</span>
</span>
movie-rating.component.js:
the setRating is bound using "&".
module.component("movieRating", {
templateUrl: "/ps-movies/movie-rating.component.html",
bindings: {
value: "<",
max: "<",
setRating: "&"
},
movie-list.component.html:
However, when using the component, the set-rating is assigned a function with two paramters model.setRating(movie, value)? And movie is actually a value from <tr ng-repeat="movie in model.movies">? but value?
<tr ng-repeat="movie in model.movies">
<td>{{movie.title}}</td>
<td>{{movie.length}}</td>
<td>
<movie-rating value="movie.rating" max="5" set-rating="model.setRating(movie, value)">
</movie-rating>
</td>
movie-list.component.js:
And in the following code model.setRating = function(movie, rating), there is no parameter that supposes to an object with property of value?
function controller($http) {
var model = this;
model.movies = [];
model.$onInit = function() {
fetchMovies($http).then(function(movies) { model.movies = movies; });
};
model.upRating = function(movie) { if(movie.rating < 5) { movie.rating += 1; } };
model.downRating = function(movie) { if(movie.rating > 1) { movie.rating -= 1; } };
model.setRating = function(movie, rating) { // rating is int, and movie is string
movie.rating = rating;
};