I've below code and want to call one Angular function form jQuery. I followed codes I found on stackoverflow questions but it does not work.
(function() {
var bng_app = angular.module('myApp', []);
bng_app.controller("myCtrl", function($scope) {
$scope.wrap_up_errors = [{
Name: "Alfreds Futterkiste",
City: "Berlin",
Country: "Germany"
}];
$scope.wrapUpError = function(a) {
$scope.wrap_up_errors = a;
console.log($scope.wrap_up_errors)
}
});
})();
function myFunc() {
angular.element($('#home')).scope().wrapUpError([{
Name: "1",
City: "2",
Country: "3"
}]);
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body id="home" data-ng-app="myApp" data-ng-controller="myCtrl">
<div class="exist-file-alert" id="exist-file-alert-id">
<table>
<tbody>
<tr data-ng-repeat="x in wrap_up_errors">
<td>{{ x.Name }}</td>
<td>{{ x.Country }}</td>
</tr>
</tbody>
</table>
</div>
<button onclick="myFunc()">Click</button>
</body>
Why data binding does not work in above snippet?
FYI I know this code does not need jQuery but this is a part of bigger functions and I need jQuery to handle myFunc() function.