HTML
<!DOCTYPE html>
<html ng-app="scheduleApp">
<head>
<title>AngularJs Schedule</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/angular.js"></script>
<script src="js/angularfire.min.js"></script>
<script src="js/firebase.js"></script>
</head>
<body>
<div class="container" ng-controller="mainController">
<div class="page-header text-center">
<h1>Schedule City</h1>
</div>
<div class="row times">
<div class="col-xs-4 text-center">
<h2>{{day.name}}</h2>
<div class="time-slot" ng-repeat="slot in day.slots">
</div>
的JavaScript
angular.module('scheduleApp',['firebase'])
.controller('mainController', function($scope){
var ref = new Firebase("https://torrid-inferno-884.firebaseIO.com/days");
var fb = $firebase(ref);
var syncObject = fb.$asObject();
syncObject.$bindTo($scope,'days');
$scope.reset = function() {
fb.$set({
monday: {
name: 'Monday',
slots: {
0900: {
time: '9:00am',
booked: false
},
0110: {
time: '11:00am',
booked: false
}
}
},
tuesday: {
name: 'Tuesday',
slots: {
0900: {
time: '9:00am',
booked: false
},
0110: {
time: '11:00am',
booked: false
}
}
}
});
};
});
错误:[$ injector:nomod]模块'scheduleApp'不可用!您要么错误拼写了模块名称,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。
答案 0 :(得分:1)
基本上你搞砸了文件加载序列。 firebasejs应该在angularfire.min.js
之前,因为它在内部使用firebase.js代码。
<script src="js/angular.js"></script>
<script src="js/firebase.js"></script>
<script src="js/angularfire.min.js"></script>
<script src="js/otherscripts.js"></script>
<强>更新强>
在控制器函数中注入$ firebase依赖项
.controller('mainController', function($scope, $firebase){