可以在以下网址查看演示:
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中抛出这么多错误的想法?有办法解决这个问题吗?
答案 0 :(得分:1)
代码中存在错误:
$scope.on("$destroy", function() {console.log("DESTROY")})
右:
$scope.$on("$destroy", function() {console.log("DESTROY")})