$ scope是AngularJS中的服务还是$ rootScope的实例?
var $injector = angular.element(document).injector();
$injector.get('$rootScope'); //it will return $rootScope
$injector.get('$scope'); //it will return undefined
Run Code Online (Sandbox Code Playgroud)
所以我怀疑$ scope不是'真正的'服务.
我今天尝试koajs并编写helloworld示例:
/**
* index.js
*/
var koa = require('koa');
var app = koa();
app.use(function*(){
this.body = 'hello world';
console.log('success!');
});
app.listen(8080);
Run Code Online (Sandbox Code Playgroud)
然后我运行index.js文件并在浏览器中访问localhost:8080,但每次刷新页面时,console.log似乎都会触发两次.为什么?