惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
Microsoft Security Blog
Microsoft Security Blog
T
Threatpost
D
DataBreaches.Net
B
Blog RSS Feed
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
N
Netflix TechBlog - Medium
O
OpenAI News
Webroot Blog
Webroot Blog
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
Google Online Security Blog
Google Online Security Blog
SecWiki News
SecWiki News
H
Help Net Security
Forbes - Security
Forbes - Security
N
News and Events Feed by Topic
aimingoo的专栏
aimingoo的专栏
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
腾讯CDC
B
Blog
H
Heimdal Security Blog
博客园 - 三生石上(FineUI控件)
C
CERT Recently Published Vulnerability Notes
L
Lohrmann on Cybersecurity
G
Google Developers Blog
Scott Helme
Scott Helme
C
CXSECURITY Database RSS Feed - CXSecurity.com
罗磊的独立博客
V
Visual Studio Blog
L
LINUX DO - 热门话题
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
C
Cisco Blogs
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google DeepMind News
Google DeepMind News
S
Security Affairs
P
Privacy & Cybersecurity Law Blog
S
Secure Thoughts
V
V2EX
雷峰网
雷峰网
Security Latest
Security Latest
H
Hacker News: Front Page
TaoSecurity Blog
TaoSecurity Blog
M
MIT News - Artificial intelligence

博客园 - volnet(可以叫我大V)

OpenAI CLIP 关键点 - 连接图像和文字 【笔记】跟吴恩达和IsaFulford学提示词工程(初级开发者入门课程) MacOS使用Charles抓去HTTPS数据 在浏览器的JavaScript里new Date().toUTCString()后,传递给C# DateTime().TryParse()会发生什么? 如何安装Docker UCP Git凭证存储(简单易懂,一学就会,认真看) - volnet(可以叫我大V) - 博客园 重启Ubuntu后Hadoop的namenode起不来的解决办法‬ ASP.NET 上传文件最大值调整 Git撤销提交 MVC模式下如何实现RegisterStartupScript等功能 RESTful接口设计原则/最佳实践(学习笔记) 如何编译MongoDB? 《硅谷之谜》读书笔记 Google的Bigtable学习笔记(不保证正确性) 软件开发到底是怎么一回事呢? 如何控制自己之2016个人目标管理 如何自适应网页的协议(http/https/……) 数据库时间戳设计 FIM相关报错汇总
AngularJS-Controller的使用-读书笔记
volnet(可以叫我大V) · 2015-10-18 · via 博客园 - volnet(可以叫我大V)

最近在读《Angular JS权威教程》读到第9页,按着示例做,居然报错,说MyController undefined,初学者不懂啊,找了个官方的文档,按着改了一下,貌似成功了,有需要的朋友参考一下,并且帮忙解释一下为啥书上的示例undefined了?

原著:

修改后:

<!doctype html>
<html ng-app="MyApp">
    <head>
        <title>Hello World</title>
        <script type="text/javascript" src="/Users/gongcen/MyPrograms/AngularJS/angular.js"></script>
    </head>
    <body>
        <script type="text/javascript" src="app.js"></script>
        <div ng-controller="MyController">
            <h1>Hello {{ clock.now }}</h1>
        </div>
    </body>
</html>

app.js

var MyApp = angular.module('MyApp', []);
MyApp.controller("MyController", function ($scope) {
    var updateClock;
    if($scope) {
        $scope.clock = {
            now : new Date()
        }
        updateClock = function(){
            $scope.clock.now = new Date();
        };
        setInterval(function(){
            $scope.$apply(updateClock);
        }, 1000);
        updateClock();
    }
});

结果: