Thursday 15 July 2010

javascript - Angular JS Bound HTML Functions Not Recognized -



javascript - Angular JS Bound HTML Functions Not Recognized -

i'm writing app draws info , displays in form of table. angular js used sorting , pagination. pagination div have injected using function in angular builds string sets $scope.pagination variable. problem ng-click functions within injected html not recognized when clicked. i'm assuming due fact not there when page rendered.

<html ng-app="listingsapp"> <body ng-controller="pagecontroller" ng-init="type=0"> <div class="pagination" ng-bind-html="paginate"></div> var listingsapp = angular.module('listingsapp', []); listingsapp.controller('pagecontroller', function($scope, $sce, $filter, $http) { $scope.buildpaginationhtml = function(showpage) { pagestring = "<span class=\"paginationitem \" ng-click=\"gotopage(" + + ")\"> " + + " </span>"; $scope.pagination = pagestring; } }

here clicking span not go gotopage function. have console log verify it. other click events on page work.

for dynamic html, have utilize $compile

listingsapp.controller('pagecontroller', function ($scope, $sce, $filter, $http, $compile) { $scope.buildpaginationhtml = function(showpage) { pagestring = $compile("<span class=\"paginationitem \" ng-click=\"gotopage(" + + ")\"> " + + " </span>")($scope); $scope.pagination = pagestring; } });

javascript angularjs

No comments:

Post a Comment