angularjs ng-click
在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的更多相关文章
- 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 ...
- part 4 AngularJS ng src directive
- Part 15 AngularJS ng init directive
The ng-init directive allows you to evaluate an expression in the current scope. In the following e ...
- table sorting–angularjs
1: <script type="text/javascript" ng:autobind 2: src="http://code.angularjs.org/0. ...
- angularjs 的笔记
angular.copy()深拷贝 angular提供了一个可以复制对象的api--copy(source,destination),它会对source对象执行深拷贝. 使用时需要注意下面几点: 如果 ...
- 从angularJS看MVVM
javascript厚积薄发走势异常迅猛,导致现在各种MV*框架百家争雄,MVVM从MVC演变而来,为javascript注入了全新的活力.我工作的业务不会涉及到angularJS[ng]这么重量级的 ...
- [译]用AngularJS构建大型ASP.NET单页应用(三)
原文地址:http://www.codeproject.com/Articles/808213/Developing-a-Large-Scale-Application-with-a-Single A ...
- angularJS看MVVM
从angularJS看MVVM javascript厚积薄发走势异常迅猛,导致现在各种MV*框架百家争雄,MVVM从MVC演变而来,为javascript注入了全新的活力.我工作的业务不会涉及到a ...
- js架构设计模式——从angularJS看MVVM
javascript厚积薄发走势异常迅猛,导致现在各种MV*框架百家争雄,MVVM从MVC演变而来,为javascript注入了全新的活力.我工作的业务不会涉及到 angularJS[ng] 这么重量 ...
- angularJS中$apply()方法详解
这篇文章主要介绍了angularJS中$apply()方法详解,需要的朋友可以参考下 对于一个在前端属于纯新手的我来说,Javascript都还是一知半解,要想直接上手angular JS,遇到的 ...
随机推荐
- Sublime Text 配置记录
sublime userSetting sublime theme sublime plug sublime userSetting 对sublime的配置 { "color_scheme& ...
- sql常用语句
选择:select * from table1 where 范围 插入:insert into table1(field1,field2) values(value1,value2) 删除:delet ...
- 使用 StringBuilder
嘿嘿,请不要说我是偷取,我只是借鉴一下.. String 对象是不可改变的.每次使用 System.String 类中的方法之一时,都要在内存中创建一个新的字符串 对象,这就需要为该新对象分配新的空间 ...
- [Jenkins] Jenkins配置自动构建时间代表意义
- Solr Cloud - SolrCloud
关于 Solr Cloud Zookeeper 入门,介绍 原理 原封不动转自 http://wiki.apache.org/solr/SolrCloud/ ,文章的内存有些过时,但是了解原理. Th ...
- spring定时器,当遇见半小时的情况时
spring定时器遇见半小时的解决方法(这里只提供注解方式) @Scheduled(fixedRate=6000000)//每隔100分钟执行方法 fixedRate的值是毫秒
- json_encode 中文乱码
用PHP的json_encode来处理中文的时候, 中文都会被编码, 变成不可读的, 类似"\u***"的格式, 还会在一定程度上增加传输的数据量. 而在PHP5.4, 这个问题终 ...
- ActiveReports最终报表设计器本地化方法介绍
ActiveReports UI界面中的所有字符信息.错误提示信息.以及一些logo.图像资源,都能够通过运行batch文件来本地化.本文主要介绍资源本地化的具体步骤: 1. 资源目录 所有可本地化的 ...
- Entity framework在用于WCF时创建数据模型的问题
众所周知,WCF的传输对象,在创建时需要在类名上标识[DataContract]以及在属性上标识[DataMember],当我们在使用Entity framework时(不考虑Code first的情 ...
- JS中循环绑定遇到的问题及解决方法
本文是原创文章,如需转载,请注明文章出处 在工作中,有时会有这样的需求:在一个页面上添加了6个按钮,然后分别为他们绑定点击事件监听器,当点击按钮1时,输出1,当点击按钮2时,输出2. 循环绑定代码如下 ...