我正在尝试使用 TempleUrl 启动这个迷你应用程序,但我做不到?:(这是简单的代码,谢谢你的时间!!
<!DOCTYPE html>
<html ng-app="app">
<head>
<title></title>
</head>
<body>
<zippy>
<input type="text" ng-model="data.message">
</zippy>
<script type="text/javascript">
var app = angular.module('app', []);
app.directive('zippy', function(){
return{
restrict: 'E',
templateUrl: hello.html
}
});
</script>
</body>
</html>
这是我在控制台中得到的,这是什么意思?我的 hello.html 与索引之一位于同一文件夹中。
ReferenceError: hello is not defined
at http://127.0.0.1:1339/index.html:24:34
at Object.d [as invoke] (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js:27:173)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js:36:469
at Array.forEach (native)
at n (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js:6:192)
at Object.<anonymous> (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js:36:438)
at Object.d [as invoke] (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js:28:127)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js:29:298
at Object.c [as get] (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js:26:479)
at r (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js:46:142)
我的 node.Js 代码很短:
var fs = require('fs');
var http = require('http');
console.log('Starting');
var config = JSON.parse(fs.readFileSync('config.json'));
var host = config.host;
var port = config.port;
var server = http.createServer(function(request, response){
console.log('Receive request: '+ request.url);
fs.readFile('public' + request.url, function(error, data){
if (error){
response.writeHead(404, {'Content-type' : 'text/plain'});
response.end('SORRY DUDE');
}else{
response.writeHead(200, {'Content-type' : 'text/html'});
response.end(data);
}
});
});