在閱讀了解它之後,我瞭解到通過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