在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. python成长之路【第九篇】:网络编程

    一.套接字 1.1.套接字套接字最初是为同一主机上的应用程序所创建,使得主机上运行的一个程序(又名一个进程)与另一个运行的程序进行通信.这就是所谓的进程间通信(Inter Process Commun ...

  2. MVC使用Membership配置

    MVC的权限管理,环境是MVC4.5,SQL Server2008 修改前 Web.config文件: <system.web> <authentication mode=" ...

  3. HDFS 核心原理

    HDFS 核心原理 2016-01-11 杜亦舒 HDFS(Hadoop Distribute File System)是一个分布式文件系统文件系统是操作系统提供的磁盘空间管理服务,只需要我们指定把文 ...

  4. iOS开发 点击某处横屏竖屏切换

    typedef NS_ENUM(NSInteger, UIInterfaceOrientation) { UIInterfaceOrientationUnknown            = UIDe ...

  5. mysql忘记密码

    修改 /etc/my.cnf 添加 skip-grant-tables 修改完后重启mysql 这样就可以直接进入mysql 然后修改mysql数据库密码 mysql>update user s ...

  6. webbench---linux压测工具

    webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好用,安装使用也特别方便,并且非常小. 1.适用系统:Linux-CentOs 2.编译安 ...

  7. zookeeper能做什么?

    Zookeeper是Hadoop的一个子项目,虽然源自hadoop,但是我发现zookeeper脱离hadoop的范畴开发分布式框架的运用越来越多.今天我想谈谈zookeeper,本文不谈如何使用zo ...

  8. float浮点数的二进制存储方式及转换

    int和float都是4字节32位表示形式.为什么float的范围大于int? float精度为6-7位.1.66*10^10的数字结果并不是166 0000 0000 指数越大,误差越大. 这些问题 ...

  9. ionic overflow:auto失效

    事情的起因是 同事上传一个很宽的table文件,因为手机屏幕宽度有限,因此要求 用户可以水平滚动页面,这样table的内容通过滚动就可以实现啦. 当时感觉很简单 给table外面的容器加个overfl ...

  10. 《精通C#》第十七章

    进程简单的说就是一个正在运行的程序,包含了运行该程序所需要的一切资源以及内存分配.线程是进程的基本执行单元,在进程的入口点(类似main())创建的第一个线程称之为主线程.只有一个主线程的进程是线程安 ...