我是角色的新手,我一直试图用firebase实例化一个角度模块,但它一直在给我:
由于以下原因无法实例化模块myApp:
Error: [$injector:nomod] Module 'myApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
这是我的app.js:
var app = angular.module('myApp',[]);
app.controller('myController', function($scope){
$scope.names = "Coder01";
});
HTML:
<!DOCTYPE html>
<html ng-app='myApp'>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-beta.2/angular.js"></script>
<script src="https://www.gstatic.com/firebasejs/live/3.0/firebase.js"></script>
<script>
var config = {
apiKey: "AIzaSyBTY8XluWdgHFadZLwhlCiD5aupBBTkezU",
authDomain: "chatroom-60d2f.firebaseapp.com",
databaseURL: "https://chatroom-60d2f.firebaseio.com",
storageBucket: "chatroom-60d2f.appspot.com",
};
firebase.initializeApp(config);
</script>
<script src="js/app.js"></script>
<title>Welcome to ChatRoom</title>
</head>
<body ng-controller="myController">
<p>Input something in the input box:</p>
<p>Name : <input type="text" ng-model="names" placeholder="Enter name here"></p>
<h1>Hello {{names}}</h1>
</body>
</html>
以下是我的所有错误:
VM3476:5 Uncaught TypeError: Cannot read property 'removeAttribute' of null(anonymous function) @ VM3310:5(anonymous function) @ VM3310:20
app.js:1 Uncaught SyntaxError: Unexpected token <
angular.js:68 Uncaught Error: [$injector:modulerr]
Failed to instantiate module myApp due to:
Error: [$injector:nomod] Module 'myApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
VM3400:5 Uncaught TypeError: Cannot read property 'removeAttribute' of null
答案 0 :(得分:1)
错误:无法实例化模块myApp ......意味着找不到/加载了角度模块(myApp)。
修复app.js文件的路径
<script src="js/app.js"></script>
我运行你的代码是plunker,它非常好。