Имеется такой код:
var app = angular.module('timetableApp', ['ngRoute']);
app.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider
.when('/test', {
templateUrl: 'js/templates/test.html',
controller: 'testCtrl',
})
.when('/', {
templateUrl: 'js/templates/schedule.html',
controller: 'indexCtrl',
});
$locationProvider.html5Mode(true);
}]);
app.controller('testCtrl', function($scope) {
//...
});
app.controller('indexCtrl',function($scope, $http) {
//...
}
В index.html:
<!-- ... -->
<div ng-view class="col-lg-8">
</div>
<!-- ... -->
schedule.html:
<div ng-repeat="lesson in scheduleArray" class="panel panel-default">
<div class="panel-body">
# {{lesson.num_lsn}} <br/>
Дисциплина: {{lesson.name}} <br/>
Преподаватель: {{lesson.short_fio}} ({{lesson.degree}}) <br/>
Корпус: {{lesson.corps}} <br/>
Аудитория {{lesson.classroom}} <br/>
</div>
</div>
ng-repeat в данном случае не работает. В чем может быть проблема? Спасибо.
IndexCtrl:
app.controller('indexCtrl',function($scope, $http) {
$scope.faculties = [];
$scope.selectedFaculty = null;
$scope.groups = [];
$scope.selectedFaculty = null;
$scope.isFilled = false;
$scope.isFacultyActive = true;
$scope.isCourseActive = false;
$scope.isGroupActive = false;
$scope.isDateActive = false;
$scope.isSubmitActive = false;
$scope.scheduleArray = [];
$scope.onFacultyChange = function() {
$scope.selectedCourse = null;
$scope.selectedGroup = null;
$scope.selectedDate = null;
$scope.isCourseActive = false;
$scope.isGroupActive = false;
$scope.isDateActive = false;
if ($scope.selectedFaculty) {
$scope.isCourseActive = true;
}
}
$scope.onCourseChange = function() {
$scope.selectedGroup = null;
$scope.selectedDate = null;
$scope.isGroupActive = false;
$scope.isDateActive = false;
if ($scope.selectedCourse) {
$scope.isGroupActive = true;
}
}
$scope.onGroupChange = function() {
$scope.selectedDate = null;
$scope.isDateActive = false;
if ($scope.selectedGroup) {
$scope.isDateActive = true;
}
}
$scope.onDateChange = function() {
//TODO: Найти лучшее решение
var comp = $scope.selectedDate.split('/');
var m = parseInt(comp[0], 10);
var d = parseInt(comp[1], 10);
var y = parseInt(comp[2], 10);
var date = new Date(y,m-1,d);
if (date.getFullYear() == y && y >= 2000 && (m > 0 && m <= 13) && (d > 0 && d <= 31)) {
$scope.isSubmitActive = true;
} else {
$scope.isSubmitActive = false;
}
}
$scope.loadGroups = function() {
$scope.groups = [];
$scope.selectedGroup = null;
$scope.method = 'POST';
$scope.url = 'ajax/getGroupOfFaculty.php';
$scope.codeStatus = "";
var data = {
faculty_id : $scope.selectedFaculty,
course : $scope.selectedCourse,
};
$http({
method: $scope.method,
url: $scope.url,
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data : $.param(data)
}).
success(function(response) {
if (response != 'null') {
var groupsArray = JSON.parse(JSON.stringify(response));
for (var i = 0; i < groupsArray.length; i++) {
$scope.groups.push({id: groupsArray[i]['id'], name: groupsArray[i]['name']});
}
}
}).
error(function(response) {
$scope.codeStatus = response || "Request failed";
});
}
$scope.searchSchedule = function() {
$scope.method = 'POST';
$scope.url = 'ajax/searchSchedule.php';
$scope.codeStatus = "";
var data = {
group : $scope.selectedGroup,
date : $scope.selectedDate
};
$http({
method: $scope.method,
url: $scope.url,
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data : $.param(data)
}).
success(function(response) {
$scope.scheduleArray = [];
if (response && response !='null') {
var scheduleArray = JSON.parse(JSON.stringify(response));
for (var i = 0; i < scheduleArray.length; i++) {
$scope.scheduleArray.push(scheduleArray[i]);
}
}
}).
error(function(response) {
$scope.codeStatus = response || "Request failed";
});
}
$scope.getFaculties = function() {
$scope.method = 'POST';
$scope.url = 'ajax/getFaculties.php';
$scope.codeStatus = "";
$http({
method: $scope.method,
url: $scope.url,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).
success(function(response) {
var facultiesArray = JSON.parse(JSON.stringify(response));
for (var i = 0; i < facultiesArray.length; i++) {
$scope.faculties.push( { id: facultiesArray[i]['id'], name: facultiesArray[i]['name'] });
}
}).
error(function(response) {
$scope.codeStatus = response || "Request failed";
});
}
});