在我当前的代码中,我使用虚拟方式来获取数据。它就像如何通过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