javascript - angular.element($0).scope()返回undefined
ringa_lee
ringa_lee 2017-04-11 12:11:56
0
1
304

狠菜鸟的一个问题,勿喷^_^
我的代码是这样的,

<html >
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src = "js/angular.js"></script>
</head>
<body  ng-app = "myApp">

<p ng-controller="myCtrl" id = "p">
    <button ng-bind = "text.id" id = "btn"></button>
</p>
<script>
angular.module("myApp",[])
        .controller("myCtrl",["$scope",function($scope){
            $scope.text = {
                id:1,
                num:20
            };
        }]);



</script>
</body>
</html>

进行测试的时候,在控制台输出angular.element($0).scope().text的时候为什么会返回undefined。。。
跪求大神解答!!膜拜ing~

ringa_lee
ringa_lee

ringa_lee

répondre à tous(1)
左手右手慢动作

楼主先在官方文档查阅一下, 什么是 Angular 里的 scope 以及 Angular和jQuery思维方式的差异.

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!