12 2014 档案
摘要:先对自定义Directive有一个大体的映像myModule.directive('myDirective',function(injectables){ var directiveDefinitionObject={ restrict:string, priori...
阅读全文
摘要:AngularJS中的DI一直以为Angular中的DI是很高大上的东西,也自己写过一个DI的demo,知道其中的难点就是最后动态代码的执行:我现在知道了参数的值,也知道了我要执行的方法/创建对象的类,那么在参数个数是动态的情况下,怎么才能执行这个方法或者新建对象呢?在我的demo中我选择的是用ev...
阅读全文
摘要:学习AngularJS的原因之一就是觉得他的DI很牛叉,为了更好的学习,在研究源码之前,想自己按照自己的思路先实现个DI,希望这个思路能够对学习源码有帮助。 1 (function(){ 2 var config; 3 var di={}; 4 //用来缓存已经生成的对象 ...
阅读全文
摘要:阅读AngularJS时,看到一些奇怪的Javascript用法。1.(function(){ a.work=function(){} })(a) 声明一个匿名函数并执行2. (new (function(){ this.al=function(){alert(123);}; })).al();...
阅读全文
posted @ 2014-12-12 21:23
502280728
摘要:页面导航 过去,一个URL代表一个页面。但是随着Ajax的兴起,情况发生的很大的变化。不同的内容可以使用同一个URL。这让浏览器中的回退、前进甚至收藏按钮都失去了作用。而AngularJS提供了一套解决方案能够避免这种情况。 怎么解决,有一个小技巧:浏览器不会因为URL中#符号后面的值改变而重新请...
阅读全文
摘要:转自http://blog.sina.com.cn/s/blog_6f9eb2dd0100sk97.html一、#的涵义 #代表网页中的一个位置。其右面的字符,就是该位置的标识符。比如, http://www.example.com/index.html#print 就代表网页index.h...
阅读全文
摘要:AngularJS 表单 AngularJS使用了MVX的结构,我们可以是传统的表单更加强大。比如过去我们得自己写一大堆验证,比过过去我们得自己转换用户的输入,现在这些工作全部可以交给AngularJS. 我们唯一要关心的就是model中的值。在AngularJS中 ,form和input其实也是...
阅读全文
摘要:FiltersAngularJS provides fileters to transfrom data from one kind to another . For example: {{user.birthday | date:'yyyy-MM-dd'}}In this example, th...
阅读全文
摘要:DirectivesIn AngularJS, we can use a variety of naming conventions to reference directives .In the AngularJS documentation, all the directive are ind...
阅读全文
摘要:Overcomming same-origin policy restrictions with JSONP.AJAX has a restriction that it can only retrieve data from the same resource.There are several...
阅读全文
摘要:AngularJS内置了$http这个服务来与后台联系。(默认会把接受到的数据转换为json)当然,还有一个$resource来提供与RESTful后台联系的服务。$http服务 $http比较简单,下面是$http的常规用法 $http.get(url,[config]) .success(fun...
阅读全文