Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

angular工作原理 #5

Open
ruanshr opened this issue Jul 13, 2017 · 0 comments
Open

angular工作原理 #5

ruanshr opened this issue Jul 13, 2017 · 0 comments

Comments

@ruanshr
Copy link
Owner

ruanshr commented Jul 13, 2017

<!doctype
html>

<script src="angular.js"></script>

Hello {{name}}!

当你用浏览器去访问index.html的时候,浏览器依次做了如下一些事情:
  1. 加载html,然后解析成DOM
  2. 加载angular.js脚本;
  3. AngularJS等待DOMContentLoaded事件的触发;
  4. AngularJS寻找ng-app指令,根据这个指令确定应用程序的边界;
    5.使用ng-app中指定的模块配置$injector;
    6.使用$injector创建$compile服务和$rootScope;
    7.使用$compile服务编译DOM并把它链接到$rootScope上;
    8.ng-init指令对scope里面的变量name进行赋值;
    9.对表达式{{name}}进行替换,于是乎,显示为“Hello World!”
    ![Uploading image.png

…]()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant