javascript - Adding ng-click handler to repeated element in angularjs -


im using angularjs 1.0.7 , trying add ng-click handler list element repeated using ng-repeat, function not fire. below html, along variations have tried in comments. have tried adding same ng-click function on different element , works fine.

<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> 

and here controller

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) {             // have our movies , can add them             $scope.movies = data;              // if there movies can show list             if ($scope.movies.length > 0) {                 $scope.showlist = true;             } else {                 $scope.showlist = false;             }         });     };      $scope.getplaylist = function (id) {         alert(id);      };  }); 

you have error in markup, function in controller called getplaylist , in markup getplaylist. note capitalization on l. here's fiddle it's fixed , there's no problem: http://jsfiddle.net/gyatesiii/z7mpw/3/


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -