重构我的 Angular 应用程序以通过工厂服务传递基本数据。现在突然 ng-repeat 没有向页面输出任何内容,它根本没有运行,而且我没有收到任何错误消息!发生了什么?
<ul ng-repeat="section in sections">
<li class="section_title {{section.active}}" >
{{section.name}}
</li>
<ul>
<li class="tutorial_title {{tutorial.active}}" ng-click="loadFromMenu([$parent.$index, $index])" ng-repeat="tutorial in AppData.section.tutorials">
{{tutorial.name}}
</li>
</ul>
</ul>
var Tutorials = angular.module('Tutorials', ['functions', 'tutorials']);
Tutorials.factory("AppData", function(){
return {
sectionNumber: 0,
tutorialNumber: 0,
questionNumber: 0,
sections: sections
}
})
Tutorials.run(function(AppData){loadFromMenu([0,0, true], AppData);})
function loadFromMenu (tut, AppData) {
if (tut[1] === AppData.tutorialNumber && tut[0] === AppData.sectionNumber && !tut[2]) {//if clicked on already playing tut
return;
}
if (tut[1] !== undefined && tut[0] !== undefined) {
AppData.tutorialNumber = tut[1];
AppData.sectionNumber = tut[0];
}
var section = AppData.sections[tut[0]];
for (var x in AppData.sections) {
AppData.sections[x].active = "inactive";
for (var y in AppData.sections[x].tutorials){
AppData.sections[x].tutorials[y].active = "inactive";
}
}
section.active = "active";
section.tutorials[tut[1]].active = "active";
//$scope.$apply();
AppData.questionNumber = 0;
if (AppData.sectionNumber === 1){
conjugationController();
}
};