[英]Angular controller not register to module
I am still new on angularjs and have a question: How does the controller still know which module it registerred to on code snippet below (found on the Angular official document): JS 我仍然对angularjs还是陌生的,并且有一个问题:控制器如何仍然知道它在下面的代码片段(在Angular官方文档中找到)上注册了哪个模块:JS
angular.module('App', []);
function Ctrl($scope) {
$scope.val = 1234.56789;
}
Html something like: HTML类似:
<html ng-app="App">
<body>
<div ng-controller="Ctrl">
........
</div>
</body>
</html>
I suspect there is something to do with bootstrap time and $scope available globally??? 我怀疑与引导时间和$ scope全球可用有关吗???
Thank you very much 非常感谢你
If you want to define a controller in a module, call the controller
method on the module: 如果要在模块中定义控制器,请在模块上调用controller
方法:
var module = angular.module('App', []);
module.controller('Ctrl', function ($scope) {
$scope.val = 1234.56789;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.