在此示例中,我找不到第一个$ scope的含义:

app.controller('HelloController', function($scope) {
  $scope.message = 'Hello World!';
});


我知道这是JavaScript,应该是该函数的参数,但是我不知道它设置了哪种参数。

有人可以帮忙吗?

谢谢!

最佳答案

$ scope参数被注入到您的控制器中,并充当控制器和视图之间的“胶水”。因此,在您的示例中,您可以像这样从HTML引用$ scope.message属性:

<div ng-controller="HelloController">
   {{message}}
</div>


我会在google +上查看文档和Angular社区。入门的好资源。

关于javascript - AngularJS函数-$ Scope,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28200727/

10-12 12:51
查看更多