angularjs - access an element inside ng-repeat when dynamic html loaded -
i trying access dom element inside dymanic loaded html http request. code using inside controller is
$http.get("/projectmanager/edit?id=" + requestid).success(function (data, status, headers, config) { data = data.trim(); var newdirective = angular.element(data); angular.element(document.getelementbyid("editdiv")).html(newdirective); $compile(newdirective)($scope); var resources = angular.element(document.getelementbyid("projectresources")).val(); (var = 0; < resources.length; i++) { var resourcedata = new projectresourcesmodel(resources[i].resourceid, resources[i].projectresourceid, resources[i].employee, resources[i].isapprover, resources[i].startdate, resources[i].enddate) $scope.resource.push(resourcedata); //$scope.$apply(); var id = "startdate" + resources[i].resourceid; angular.element(document.getelementbyid(id)).datetimepicker({ defaultdate: resources[i].startdate, format: 'mm/dd/yyyy', }) } })
i trying access element particular id present in array element.
view html inside ng-repeat follows
<div> <div class="form-group"> <div class='input-group date' id='startdate{{item.resourceid}}'> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> <input ng-model="item.startdate" type='text' id="txtstartdate{{item.resourceid}}" class="form-control" /> </div> </div> </div> </div>
i have attach bootstrap datetimepicker textbox want access div inside ng-repeat id present inside ng-repeat array. when access item id inside success of request not getting element. e.g id of div startdate151 after view binding.
so tried using $scope.$apply() able attach datepicker element inside ng-repeat started getting console error
error: [$rootscope:inprog] $digest in progress
can me resolve or can use other alternative in situation.
Comments
Post a Comment