(四)左右ng-app自己主动bootstrap相框
2015-09-24 19:51
316 查看
博客之前
(三)ng-app的使用困惑和angularJS框架的自己主动载入 提出了使用ng-app指令的情况。之前认为出现第4和第5种情况非常奇怪,由于仅仅看到了现象,没有看到本质。JS错误。最直观的表现方式就是:弹出一个非常不友好的JS错误窗体。
当脚本出现了未捕获的错误,浏览器才会弹出错误提示。另一种比較隐晦的表示:在浏览器的控制台输出错误信息。这提示我们:使用JS框架的时候,一定要用下F12看看控制台是否有错误。
第3种情况 和 第5种情况:不带属性的ng-app模块不能自己主动载入,用F12发现控制台报错:
SCRIPT5022: [$injector:modulerr]
Failed to instantiate module app1 due to:
Error: [$injector:nomod] Module 'app1' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument。
什么意思呢?大概就是我们使用了ng-app,要求自己主动载入我们自己定义的模块,可是我们却没有提供这些模块。
再看下官方的ngApp说明文档:
Use this directive to auto-bootstrap an AngularJS application. The ngApp directive designates the root element of the application and is typically placed near the root element of the page - e.g. on the <body> or <html> tags.Only
one AngularJS application can be auto-bootstrapped per HTML document. The first ngApp found in the document will be used to define the root element to auto-bootstrap as an application。
1、假设在html中定义了ng-app,那么angular框架会自己主动初始化,无论它有没有带属性值。
假设没有使用ng-app,那么须要自己手动初始化。
2、假设ng-app没有属性值。angular会默认创建一个模块作为root,然后启动框架。
3、ng-app属性假设有值,即自己定义module。也会被解析出来,前提是我们必须先创建module。
也就是说ng-app就是用来自己主动启动angular框架的,是否带属性值的区别在于:根模块的创建。究竟是默认的,还是我们自已定义。
(三)ng-app的使用困惑和angularJS框架的自己主动载入 提出了使用ng-app指令的情况。之前认为出现第4和第5种情况非常奇怪,由于仅仅看到了现象,没有看到本质。JS错误。最直观的表现方式就是:弹出一个非常不友好的JS错误窗体。
当脚本出现了未捕获的错误,浏览器才会弹出错误提示。另一种比較隐晦的表示:在浏览器的控制台输出错误信息。这提示我们:使用JS框架的时候,一定要用下F12看看控制台是否有错误。
第3种情况 和 第5种情况:不带属性的ng-app模块不能自己主动载入,用F12发现控制台报错:
SCRIPT5022: [$injector:modulerr]
Failed to instantiate module app1 due to:
Error: [$injector:nomod] Module 'app1' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument。
什么意思呢?大概就是我们使用了ng-app,要求自己主动载入我们自己定义的模块,可是我们却没有提供这些模块。
再看下官方的ngApp说明文档:
Use this directive to auto-bootstrap an AngularJS application. The ngApp directive designates the root element of the application and is typically placed near the root element of the page - e.g. on the <body> or <html> tags.Only
one AngularJS application can be auto-bootstrapped per HTML document. The first ngApp found in the document will be used to define the root element to auto-bootstrap as an application。
1、假设在html中定义了ng-app,那么angular框架会自己主动初始化,无论它有没有带属性值。
假设没有使用ng-app,那么须要自己手动初始化。
2、假设ng-app没有属性值。angular会默认创建一个模块作为root,然后启动框架。
3、ng-app属性假设有值,即自己定义module。也会被解析出来,前提是我们必须先创建module。
也就是说ng-app就是用来自己主动启动angular框架的,是否带属性值的区别在于:根模块的创建。究竟是默认的,还是我们自已定义。
相关文章推荐
- 2 app应用广告推广
- Android开发环境部署
- Android批量打包-如何一秒内打完几百个apk渠道包
- Android批量打包-如何一秒内打几十个apk渠道包
- Android学习系列--App列表之拖拽ListView(下)
- Android 手势操作GestureDetector
- Android学习系列--App列表之拖拽ListView(上)
- android内存文件读写
- CocoStudio基础教程(5)使用CocoStudio场景编辑器关联组件
- Android.mk写法
- 线程池ThreadPoolExecutor使用简介
- android四大组件详解
- Cocos2d-x中的CC_CALLBACK_0,1,2,3
- iOS_XML与JSON解析
- Android中自定义弹窗提醒控件
- Android学习实践:7.使用布局文件进行事件绑定
- WebViewClient与WebChromeClient的区别
- 编写 Android 触摸屏手势识别程序
- IOS Alcatraz Xcode6.4安装指南
- Unity3D:NGUI 深入剖析NGUI的游戏UI架构