gpt4 book ai didi

angularjs - 为什么这个 Controller 函数被调用不止一次

转载 作者:行者123 更新时间:2023-12-02 03:21:41 27 4
gpt4 key购买 nike

<分区>

下面的代码(也在 Plunker 中)。在控制台上,我看到打印了多个 foo

<html>
<head>
<script src='https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js'></script>
</head>
<body>
<div ng-app='theApp'>
<div ng-controller='TheController as ctl'>
{{ctl.foo()}}
</div>
</div>
<script>
angular.module('theApp', [])
.controller('TheController', [function() {
this.foo = function() {
console.log('foo');
};
}]);
</script>
</body>
</html>

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com