angularjs 1.0.7を使用していて、ng-repeatを使用して繰り返されるリスト要素にng-clickハンドラを追加しようとしていますが、関数は起動しません。以下は、HTML と、コメントで試したバリエーションです。別の要素に同じ ng-click 関数を追加しようとしましたが、正常に動作します。
<div class="results" ng-cloak ng-show="showList != 0">
<ul>
<li ng-repeat="movie in movies" ng-click="getPlaylist(movie.id)">{{ movie.title }}</li>
<!--<li ng-repeat="movie in movies" ng-click="getPlaylist({{movie.id}})">{{ movie.title }}</li>-->
<!--<li ng-repeat="movie in movies" ng-click="getPlaylist('movie.id')">{{ movie.title }}</li>-->
<!--<li ng-repeat="movie in movies" ng-click="getPlaylist(\'{{movie.id}}\')">{{ movie.title }}</li>-->
</ul>
</div>
そしてコントローラーはこちら
main.controller('MoviesListCtrl', function($scope, $http, playlist) {
$scope.movies = [];
$scope.showList = false;
$scope.getMoviesList = function (val) {
var link = 'titles?q=' + val + '&limit=10'
$http.get(link).success(function (data) {
// now we have all our movies and can add them
$scope.movies = data;
// if there any movies we can show the list
if ($scope.movies.length > 0) {
$scope.showList = true;
} else {
$scope.showList = false;
}
});
};
$scope.getPlayList = function (id) {
alert(id);
};
});