在angularjs的controller中一段代码,展示如下:

var sortList = new SortList();

sortList.setSorts([$scope.year_invest_sort]);

$scope.sorts = sortList.getSorts();

$scope.bySort = function(sortListItem){

if(sortListItem.sort == '0'){

sortList.setSorts([$scope.year_invest_sort_rise]);

}else if(sortListItem.sort == '1'){

sortList.setSorts([$scope.year_invest_sort_drop]);

}else if(sortListItem.sort == '2'){

sortList.setSorts([$scope.year_invest_sort]);

}

}

$scope.sorts = sortList.getSorts();

html页面div中有个ng-click="bySrot(1)",点击之后sortList是什么?

这样写的话sortList仍然是$scope.year_invest_sort,没有达到想要的结果$scope.year_invest_sort_drop,因为最后一行代码$scope.sorts = sortList.getSorts()

没有执行,应该写到方法里面才能执行得到想要的结果。看似简单,也容易忽视。略记录下。

angularjs ng-click的更多相关文章

  1. Part 6 AngularJS ng repeat directive

    ng-repeat is similar to foreach loop in C#. Let us understand this with an example. Here is what we ...

  2. part 4 AngularJS ng src directive

  3. Part 15 AngularJS ng init directive

    The ng-init directive allows you to evaluate an expression in the current scope.  In the following e ...

  4. table sorting–angularjs

    1: <script type="text/javascript" ng:autobind 2: src="http://code.angularjs.org/0. ...

  5. angularjs 的笔记

    angular.copy()深拷贝 angular提供了一个可以复制对象的api--copy(source,destination),它会对source对象执行深拷贝. 使用时需要注意下面几点: 如果 ...

  6. 从angularJS看MVVM

    javascript厚积薄发走势异常迅猛,导致现在各种MV*框架百家争雄,MVVM从MVC演变而来,为javascript注入了全新的活力.我工作的业务不会涉及到angularJS[ng]这么重量级的 ...

  7. [译]用AngularJS构建大型ASP.NET单页应用(三)

    原文地址:http://www.codeproject.com/Articles/808213/Developing-a-Large-Scale-Application-with-a-Single A ...

  8. angularJS看MVVM

    从angularJS看MVVM   javascript厚积薄发走势异常迅猛,导致现在各种MV*框架百家争雄,MVVM从MVC演变而来,为javascript注入了全新的活力.我工作的业务不会涉及到a ...

  9. js架构设计模式——从angularJS看MVVM

    javascript厚积薄发走势异常迅猛,导致现在各种MV*框架百家争雄,MVVM从MVC演变而来,为javascript注入了全新的活力.我工作的业务不会涉及到 angularJS[ng] 这么重量 ...

  10. angularJS中$apply()方法详解

    这篇文章主要介绍了angularJS中$apply()方法详解,需要的朋友可以参考下   对于一个在前端属于纯新手的我来说,Javascript都还是一知半解,要想直接上手angular JS,遇到的 ...

随机推荐

  1. spring-task

    cronExpression的配置说明,具体使用以及参数请百度google 字段   允许值   允许的特殊字符 秒    0-59    , - * / 分    0-59    , - * / 小 ...

  2. adeng朝花夕拾

    ============================C/C++基础拾遗===================================== 1.指针: 函数指针做函数参数 回调函数 语法现象 ...

  3. 【Java】异常处理_学习笔记

    异常: 1.格式1: try { //业务代码 } catch(Exception e) { //异常处理代码 } 说明: a.   异常抛出:执行try里的代码,系统会自动生成一个异常对象,该对象会 ...

  4. 解决redhat 没注册的情况下yum无法使用的问题

       官网下载的rhel,安装后是没有配置yum源的,需要自己配置yum源.网络上的很难找到rhel的yum源,但是在ISO镜像里面有很多redhat提供的软件包,也是正版软件,我们可以把这个拷贝出来 ...

  5. 转:C/C++程序员简历模板

    https://github.com/geekcompany/ResumeSample/blob/master/c.md 本简历模板由国内首家互联网人才拍卖网站「 JobDeer.com 」提供. ( ...

  6. [SoapUI] 在SoapUI里获取Excel中多行数据并存入List

    ArrayList<ArrayList<String>> getCellValuesH( String filePath, String sheetName,int tr1,i ...

  7. malloc error:初始值设定元素不是常量

    #include <stdio.h> #include <stdlib.h> char *buf = (char *)malloc(BUFSIZ); setbuf(stdout ...

  8. SAP采购订单历史明细报表源代码(自己收藏)

    SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF } ...

  9. http响应需要记住的状态码

    200:请求成功. 301:被请求的资源已永久移动到新位置.302:请求的资源现在临时从不同的 URI 响应请求.401:当前请求需要用户验证.403:服务器已经理解请求,但是拒绝执行它. 404:请 ...

  10. spring框架学习(二)依赖注入

    spring框架为我们提供了三种注入方式,分别是set注入,构造方法注入,接口注入.接口注入不作要求,下面介绍前两种方式. 1,set注入 采用属性的set方法进行初始化,就成为set注入. 1)给普 ...