为什么 "hello world" angularJS 代码会在 Plunker 上抛出很多错误?
Why does "hello world" angularJS code throws A LOT OF errors on Plunker?
可在以下位置查看演示:
http://plnkr.co/edit/tLiAWIQ3bCAo4z4VFYTc?p=preview
script.js
var app=angular.module('app',[])
app.controller('MyController', function($scope) {
console.log("TEST")
$scope.on("$destroy", function() {console.log("DESTROY")})
})
index.html:
<!DOCTYPE html>
<html ng-app='app'>
<head>
<script data-require="angular.js@*" data-semver="1.4.0-beta.3" src="https://code.angularjs.org/1.4.0-beta.3/angular.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body ng-controller="MyController">
<h1>Hello Plunker!</h1>
</body>
</html>
有没有人知道为什么 plunkr 会抛出这么多错误?有办法解决这个问题吗?
代码有误:
$scope.on("$destroy", function() {console.log("DESTROY")})
右:
$scope.$on("$destroy", function() {console.log("DESTROY")})
可在以下位置查看演示:
http://plnkr.co/edit/tLiAWIQ3bCAo4z4VFYTc?p=preview
script.js
var app=angular.module('app',[])
app.controller('MyController', function($scope) {
console.log("TEST")
$scope.on("$destroy", function() {console.log("DESTROY")})
})
index.html:
<!DOCTYPE html>
<html ng-app='app'>
<head>
<script data-require="angular.js@*" data-semver="1.4.0-beta.3" src="https://code.angularjs.org/1.4.0-beta.3/angular.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body ng-controller="MyController">
<h1>Hello Plunker!</h1>
</body>
</html>
有没有人知道为什么 plunkr 会抛出这么多错误?有办法解决这个问题吗?
代码有误:
$scope.on("$destroy", function() {console.log("DESTROY")})
右:
$scope.$on("$destroy", function() {console.log("DESTROY")})