Using jQuery's $.ajax within an angularJS controller

后端 未结 1 1323
眼角桃花
眼角桃花 2020-12-03 04:13

How can I use jQuery\'s $.ajax() function inside an angularJS controller (instead of angularJS built-in $http) so that the $scope values can be accessed from a view/template

相关标签:
1条回答
  • 2020-12-03 04:27

    Because using jQuery ajax is out of the world of angular, you need to wrap your $scope assignment inside of

    $scope.$apply(function(){
        $scope.user = data;
    });
    

    Angular's $http comes pre-built with the digest cycle triggering mechanism.

    0 讨论(0)
提交回复
热议问题