首頁  >  問答  >  主體

angular.js - angular 模組的run方法如何使用

求解決:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script> 
</head>
<body>
    <p ng-app="myApp">{{test}}</p>
    <script>
        var app = angular.module("myApp", []);
        console.log(app);
        app.run(function($rootscope){$rootscope.test = 'hello test'});
    </script>
</body>
</html>

報錯誤:

阿神阿神2684 天前486

全部回覆(2)我來回復

  • 迷茫

    迷茫2017-05-15 17:02:39

    $rootscope --> $rootScope. 你拼錯了。 。 。

    回覆
    0
  • phpcn_u1582

    phpcn_u15822017-05-15 17:02:39

    你的$rootScope的大小寫錯了,所以導致報錯,並不是run方法的問題

    回覆
    0
  • 取消回覆