在阅读了解它之后,我了解到通过ajax加载的html不绑定到我的角度应用程序。我已经尝试过1000次,但无法获得'customers-invoice.html'来理解角度。任何想法将不胜感激。AngularJS将范围绑定到html后ajax加载()函数
<body ng-cloak ng-app="myApp">
<main id="main">
<div ng-controller='Ctrl'>
<a ng-click="openInvoice(data.invoiceRef)" class="btn">View</a>
</div>
</div>
</body>
var app = angular.module('myApp', []);
app.controller('Ctrl', function($scope, $compile) {
$scope.invoice = {}
$scope.openInvoice = function(ref) {
$scope.invoice.ref = ref;
var html = $('#main');
html.load('customers-invoice.html')
$compile(html)($scope);
}
}
我终于选择了这个解决方案,因为它使用了自己的方法。谢谢 – ClaraG