在我當前的代碼中,我使用虛擬方式來獲取數據。它就像如何通過Ajax填充範圍變量進入控制器?
var controlMeetings = $.ajax({
type: "GET",
url: "./Info.xml",
contentType: "text/xml",
dataType: "xml",
success: function (dataSource) {
controlMeetings = PureJson(dataSource);
}
});
function MeetingsCtrl($scope, $compile) {
$scope.meetings = controlMeetings;
$('#div1').html(
$compile(
'<ul><li ng-repeat="meeting in meetings"><a>{{meeting.count}}</a> <ul><li ng-repeat="child in meeting.children">{{child.meet}}</li></ul></li></ul>'
)($scope)
);
$('#div1').prepend('<div class="mHeader">Race cources</div>');
}
它顯然不好(是我從這個代碼感到羞恥),但它的工作atm。問題是如何在控制器中實際填充$ cope.meetings變量並避免使用全局變量?
我想你可以用角方式接地做,請按照教程 - http://egghead.io – Neil 2013-04-30 08:23:21