Skip to content

Instantly share code, notes, and snippets.

@cre-o
Last active February 23, 2019 19:00
Show Gist options
  • Save cre-o/f138bdf1cf9e36eed3f9f73b54bb8260 to your computer and use it in GitHub Desktop.
Save cre-o/f138bdf1cf9e36eed3f9f73b54bb8260 to your computer and use it in GitHub Desktop.
Data sync between jQuery and Angular 1

Html file

<div class="js-synced-tabs" ng-click="syncWithjQuery()" data-tab-id="1" style="width: 0; height: 0;"></div>
<div class="container" id="draggable-status-list">
<!-- appends from jQuery -->
</div>

jQuery file

httpRequest('GET', 'API/point' , function (data) ....
$.each(data, function (i, v) {
html += '<a onclick="'+"jQuery('.js-synced-tabs').data('tab-id',"+ v.id +"); jQuery('.js-synced-tabs').click();"+'">' 
        + v.name
        + '</a>';
$('body').find('.container').html(html);
})

Angular file

$scope.syncWithjQuery = function() {
  $rootScope.issue_tab = angular.element('.js-synced-tabs').data('tab-id');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment