Click here to Skip to main content
15,879,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I m using angularjs and jquery for cordova on visual studio. for android 4.1.2 when i use $scope.$apply() or $scope.$apply(funtion() {..}) to refresh ng-repeat mobile application crash. log says win death

Is there any way do this.

HTML
<div id="workorder" data-role="page" data-ng-controller="workorderctrl">
    <div data-role="header" data-position="fixed">
        <h1>Header</h1>
    </div>
    <div data-role="content">
        <div id="wotab-content" data-ng-repeat="wo in workorderdata">
        </div>
    </div>
</div>


JavaScript
function reloadTransition(data) {
    $scope.workorderdata = data
    $scope.$apply();
    $('#workorder').trigger("create");
}
Posted
Updated 1-Mar-17 2:33am

1 solution

Since this was apparently never answered, for anyone reading the question, the answer is that you don't have to do anything.

If workorderdata is a list that changes, when it is changed, angular will run a $digest cycle and the display list should reflect the changes immediately. In fact you will probably get an error on the $apply that $digest is already in progress. Plus mixing JQuery and angular (last statement, not sure what it is attempting) isn't a good practice.

JQuery should be used as little as possible (let angular use it if it needs it only). Angular has a function that should be used instead if you absolutely need it (angular.element). This should always be checked with an "if (myElem)" since unit tests will not have the DOM loaded (unless you fake it some way).
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900