我试图从JQuery访问AngularJS视图。以下是我的代码。感谢您对此的帮助。我相信它与使用ng-bind由AngularJS创建的DOM操作有关,但我不确定如何解决这个问题。 TQ
[HTML]
<div class="row" ng-app="ProjectApp" ng-controller="ProjectController">
<span id="ajaxPath">{{ajaxPath}}</span>
<div>
[controller] - 设置ajaxPath值
angular.module('ProjectApp')
.controller('ProjectController', function($scope){
$scope.ajaxPath = "http://localhost:8080/api/projectlist";
});
[jquery] - 获取ajaxPath值
console.log($('#ajaxPath').text());
//output = {{ajaxPath}}