【问题标题】:Why does "hello world" angularJS code throws A LOT OF errors on Plunker?为什么“hello world”angularJS 代码会在 Plunker 上引发很多错误?
【发布时间】:2019-12-24 19:26:25
【问题描述】:

演示可以在以下位置查看:

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 中会抛出这么多错误?有没有办法解决这个问题?

【问题讨论】:

    标签: javascript angularjs iframe plunker


    【解决方案1】:

    代码有错误:

    $scope.on("$destroy", function() {console.log("DESTROY")})
    

    对:

    $scope.$on("$destroy", function() {console.log("DESTROY")})
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-24
      • 1970-01-01
      • 2020-03-25
      • 1970-01-01
      • 1970-01-01
      • 2017-03-28
      相关资源
      最近更新 更多