1. templateurl和路由之类的要在web server下运行。
2. 使用模板replace设为true,模板里也要有相应的标签,否则不出现任何数据。
3. 1.2版本之后,ngroute模块独立。
4.空的controller不定义会出错。
5.directive的link参数是有顺序的:scope,element,attrs,ctrl
6.ng-repeat不能循环重复的对象。hack: ng-repeat="thing in things track by $id($index)"
7.尽量更新的是变量的属性而不是单个变量本身。
8.注意ng-repeat,ng-controller等会产生独立作用域。
9.当jquery载入,则使用jquery,否则使用内置jqlite。all element references in angular are always wrapped with jquery or jqlite; they are never raw dom references.
10.uncaught error: [$location:ihshprfx] a标签没有去掉 <a href="#" ng-click="somemethod();"></a>
11.error: listen eacces 当在linux下,会出现这个错误,因为你监听的端口的原因,这里我的是33。把它改成8080或3030之类大的端口数就可以了。有一个规定,这些端口最好是大于1024。
12. select在没有ng-model的时候,无法显示。同理,当遇到无法显示最好看文档少了什么。
补:当ng-options的源,跟书写不相配时会出现全部选择的情况,如下:
var a = [{"id":1,"name":"ryan"}....] ,ng-options="item.i as item.name for item in a" // i与id不同
----------------------------------------------------------------------------------------
13.ng-bind-html-unsafe已去除,可以用['ngsanitize'] 模块或使用$sce服务
from stackoverflow
you indicated that you're using angular 1.2.0... as one of the other comments indicated, ng-bind-html-unsafe has been deprecated.
instead, you'll want to do something like this:
in your controller, inject the $sce service, and mark the html as "trusted":
note that you'll want to be using 1.2.0-rc3 or newer. (they fixed a bug in rc3 that prevented "watchers" from working properly on trusted html.)
查看更多angularjs的语法,大家可以关注:,也希望大家多多支持移动技术网。
如对本文有疑问, 点击进行留言回复!!
解决三元运算符 报错“SyntaxError: can''t assign to conditional expression”
解决angular 使用原生拖拽页面卡顿及表单控件输入延迟问题
使用 Angular RouteReuseStrategy 缓存(路由)组件的实例代码
分享Angular http interceptors 拦截器使用(推荐)
网友评论