导航:首页 > 净水问答 > angular事件过滤

angular事件过滤

发布时间:2021-02-26 13:45:27

㈠ angular添加事件怎么阻止冒泡

我也刚学,不知道写法合不合理,但是的确解决问题了。。。
刚好遇到,两种情况吧
第一种函数写在controller里面的
$scope.click = function($event){
$event.stopPropagation();//在函数体内加上这句代码就好
}
第二种函数写dom里面通过ng-click进行调用的
<a class="saveSort saveCheckConfig" href="javascript:void(0);" ng-click=saveCheckConfig($event)>保存</a>'

然后controller面写$scope.saveCheckConfig = function($event){$event.stopPropagation();}

㈡ angularjs内置过滤器filter能不能获取过滤后的数据

AngularJS的内置过滤器使用方法:
一个过滤器,不带参数的情况
{{expression | filter}}

一个过滤器,带参数的情况
{{expression | filter:arguments}}

一个过滤器,带多个参数的情况
{{expression | filter: arg1: arg2: ...}}

多个过滤器,不带参数的情况
{{expression | filter1 | filter2 | ...}}
分别使用以下AngularJS的内置过滤器
currency

currency允许我们设置自己的货币符号,默认情况下会采用客户端所处区域的货币符号。
可以这样使用:{{ 3600 | currency: "$¥"}}
返回结果为$¥123.00
online code点击预览

number

number过滤器将数字格式化成文本,它的参数是可选的,用来控制小数点后的截取位数
如果传入的是一个非数字字符,会返回空字符串
可以这样使用:{{ 3600 | number:2}}
返回结果为:3,600.00
online code点击预览

lowercase

lowercase将字符串转换为小写
可以这样使用:{{ "HEllo" | lowercase}}
返回结果为:hello
online code点击预览

uppercase

uppercase将字符串转换为大写
可以这样使用:{{ "HEllo" | uppercase}}
返回结果为:HELLO
online code点击预览

json

json过滤器可以将一个JSON或者JavaScript对象转换成字符串。
这个过滤器对调试相当有用
可以这样使用:{{ {"name":"dreamapple","language":"AngularJS"} | json}}
返回结果为:{ "name": "dreamapple", "language": "AngularJS" }
online code点击预览

date

date过滤器将日期过滤成你想要的格式,这个实在是很好的过滤器。
这个过滤器用法很多我这里列举几种常用的
{{ today | date: "yyyy - mm - dd"}}
结果为:2015 - 15 - 13
{{ today | date: "yyyy - mm - dd HH:mm::ss"}}
结果为:2015 - 18 - 13 20:18::38
[online code](2015 - 18 - 13 20:18::38)

㈢ angularjs中有多个过滤器使用方法

一、在视图模板(View Template)中使用
在表达式中应用Filters (过滤器)
需要遵循格式如下:
{{ expression | filter }} 即 {{ 表达式 | 过滤器 }}
例如:{{ 12 | currency }} 输出为 $12.00在输出结果中应用Filters (过滤器)
通俗点讲就是Filter的叠加--前一filter的输出结果作为后一filter的输入数据源.
需要遵循格式如下:
{{ expression | filter1 | filter2 | ... }} 即 表达式(expression)使用filter1过滤后再使用filter2过滤...
带参数的Filter
Filter后面可以跟一个或多个参数,用来帮助实现特殊要求、需求的filter.
需要遵循格式如下:
{{ expression | filter:argument1:argument2:... }}
示例: {{ 1234 | number:2 }} = 1,234.00END
二、使用 AngluarJS 内置Filter
AngularJS为我们提供了9个内建的过滤器
分别是currency, date, filter, json, limitTo, uppercase, lowercase, number, orderBy。
具体的用法在AngularJS的文档中都有详细说明。下面只说几个常用的。
currency filter(货币过滤器)
currency – 用来将变量转换成货币表现形式
如:{{ amount | currency}}
uppercase/lowercase filter(字母大小写filter)如:
{{ "lower cap string" | uppercase }}
<input ng-model="userInput"> Uppercased: {{ userInput | uppercase }}
date filter (日期filter)
如:
{{ 1304375948024 | date }}
{{ 1304375948024 | date:"MM/dd/yyyy @ h:mma" }}
json filter
如:
{{ {foo: "bar", baz: 23} | json }}
END
在controllers, services和drictives中使用filter1可以在AngularJS的controller, service或者driective中使用filter, 这时候你需要将依赖的filter名字加入到controller, service或者directive的依赖中去。
2在controller中直接使用filter, 这样controller可以根据自身需要而适时调用filterEND
三、自定义filter(过滤器)
1AngularJS编写自定义过滤器的形式和AngularJS的factory service非常相像,一定记得它返回一个对象或者是一个函数即可,编写的时候,只需要一个带有一个以上参数的函数即可。
2格式大致如:
app.filter('filter(过滤器)名称',function(){return function(需要过滤的对象,过滤器参数1,过滤器参数2,...){//...执行业务逻辑代码return 处理后的对象;
}
});

㈣ angular filter 对数组过滤时,排除arr怎么做

js:
$scope.arr = [
["212","上","下","左","右"],
["12","1","2","3","4"],
]

html:
<input type="text" ng-model="text">

<tr ng-repeat="dataTr in arr | filter:text">
<td ng-repeat="dataTd in dataTr">
<ng-switch on="$first">
<span ng-switch-when="true">{{index+1}}</span>
<span ng-switch-default>{{dataTd}}</span>
</ng-switch>
</td>
</tr>

㈤ 如何利用AngularJs快速搭建前端基本框架

https://github.com/EricTop3
刚开始学,搜集了一些被人的例子,,一起分回享一下,学习答中

㈥ angularjs filter怎么绑定事件

直接上代码 你复制编译器里改一把就会了

<!doctypehtml>
<htmlng-app="lesson"ng-controller="lesson5">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8">
<title>
LESSON5
</title>
<linkrel="stylesheet"type="text/css"href="css/main.css"/>
<style>
#content1{padding:16px;}
</style>
</head>
<body>
<divstyle="margin-bottom:50px;">
<formng-submit="SubmitForm()">
<ul>
<li>姓名:<inputng-model="NewName"/></li>
<li>年龄:<inputng-model="NewAge"/></li>
<li><inputtype="submit"value="提交"/></li>
</ul>
</form>
</div>

<divstyle="margin-bottom:50px;">
点击数:<b>{{Counter}}</b>
<inputtype="text"ng-change="CounterClick()"ng-model="counterInput"/><br/>
<inputtype="text"ng-keypress="CounterClick()"ng-model="counterInput1"/>
<buttonng-click="CounterClick()">点击</button>
</div>
<divstyle="margin-bottom:50px;">
<png-show="ContentFlag">这里是文章内容</p>
<buttonng-click="HideContent()">隐藏</button>
</div>
<table>
<thead>
<tr>
<th>姓名</th>
<th>年龄</th>
<th>星座</th>
</tr>
</thead>
<tbody>
<trng-repeat="xinUserInfoList">
<td>{{x[0]}}</td>
<td>{{x[1]}}</td>
<td>{{x[2]}}</td>
</tr>
</tbody>
</table>
<tablestyle="margin-top:30px;border:1pxsolidblue;">
<thead>
<tr>
<th>ID</th>
<th>姓名</th>
<th>年龄</th>
<th>星座</th>
<th>工作年限</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<trng-repeat="xinUserEntityList|orderBy:['Age','-WorkYear']|filter:'座'">
<td>{{$index+1}}</td>
<td>{{x.Name|uppercase}}</td>
<td>{{x.Age}}</td>
<td>{{x.Constellation}}</td>
<td>{{x.WorkYear}}</td>
<td><buttonng-click="DeleteUser(x.Name)">删除</button></td>
</tr>
</tbody>
</table>
<scriptsrc="scripts/angular-1.4.6.min.js"></script>
<script>
varapp=angular.mole("lesson",[]);
app.controller("lesson5",function($scope){
$scope.UserNameList=["Tom","Jerry","David","Tim"];
$scope.UserEntityList=[
{'Name':'Tim','Age':39,'Constellation':'摩羯座','WorkYear':19},
{'Name':'Tom','Age':26,'Constellation':'水瓶座','WorkYear':39},
{'Name':'David','Age':28,'Constellation':'天秤座','WorkYear':7},
{'Name':'Jerry','Age':26,'Constellation':'巨蟹座','WorkYear':139}
];
$scope.UserInfoList=[
["Tom",26,"水瓶座"],
["Jerry",27,"巨蟹座"],
["David",28,"天秤座"],
["Tim",39,"摩羯座"]
];
$scope.DeleteUser=function(userName){
$scope.UserEntityList.forEach(function(user,i,list){
if(user.Name==userName){
list.splice(i,1);
}
})
}

$scope.Counter=0;
$scope.CounterClick=function(){
$scope.Counter=$scope.Counter+1;
}

$scope.ContentFlag=true;
$scope.HideContent=function(){
$scope.ContentFlag=!$scope.ContentFlag;
}

$scope.SubmitForm=function(){
varname=$scope.NewName;
varage=$scope.NewAge;
console.log(
{name:name,age:age}
);
returnfalse;
}

});

</script>

</body>
</html>

㈦ angular中怎样在控制器里面过滤时间戳

使用$filter

㈧ angularjs $filter过滤器问题

推荐使用angular-ui-grid:
controller:
varapp=angular.mole('app',['ngTouch','ui.grid','ui.grid.pagination']);

app.controller('MainCtrl',['$scope','$http',function($scope,$http){
$scope.gridOptions1={
paginationPageSizes:[25,50,75],
paginationPageSize:25,
columnDefs:[
{name:'name'},
{name:'gender'},
{name:'company'}
]
};
}]);

html:
<divui-grid="gridOptions1"ui-grid-paginationclass="grid"></div>

㈨ Angularjs 过滤器能获取到过滤后的数据吗

|AngularJS的内置过滤器使用方法:
一个过滤器,不带参数的情况
{{expression | filter}}

一个过滤器,带参数的情况
{{expression | filter:arguments}}

一个过滤器,带多个参数的情况
{{expression | filter: arg1: arg2: ...}}

多个过滤器,不带参数的情况
{{expression | filter1 | filter2 | ...}}
分别使用以下AngularJS的内置过滤器
currency

currency允许我们设置自己的货币符号,默认情况下会采用客户端所处区域的货币符号。
可以这样使用:{{ 3600 | currency: "$¥"}}
返回结果为$¥123.00
online code点击预览

number

number过滤器将数字格式化成文本,它的参数是可选的,用来控制小数点后的截取位数
如果传入的是一个非数字字符,会返回空字符串
可以这样使用:{{ 3600 | number:2}}
返回结果为:3,600.00
online code点击预览

lowercase

lowercase将字符串转换为小写
可以这样使用:{{ "HEllo" | lowercase}}
返回结果为:hello
online code点击预览

uppercase

uppercase将字符串转换为大写
可以这样使用:{{ "HEllo" | uppercase}}
返回结果为:HELLO
online code点击预览

json

json过滤器可以将一个JSON或者JavaScript对象转换成字符串。
这个过滤器对调试相当有用
可以这样使用:{{ {"name":"dreamapple","language":"AngularJS"} | json}}
返回结果为:{ "name": "dreamapple", "language": "AngularJS" }
online code点击预览

date

date过滤器将日期过滤成你想要的格式,这个实在是很好的过滤器。
这个过滤器用法很多我这里列举几种常用的
{{ today | date: "yyyy - mm - dd"}}
结果为:2015 - 15 - 13
{{ today | date: "yyyy - mm - dd HH:mm::ss"}}
结果为:2015 - 18 - 13 20:18::38
[online code](2015 - 18 - 13 20:18::38)

㈩ Angularjs过滤器使用详解

给大家介绍下什么是
AngularJS?
AngularJS是一个为动态WEB应用设计的结构框架。它能让你使用HTML作为模板语言,通过扩展HTML的语法,让你能更清楚、简洁地构建你的应用组件。它的创新点在于,利用󰀃数据绑定󰀃和󰀃依赖注入,它使你不用再写大量的代码了。这些全都是通过浏览器端的Javascript实现,这也使得它能够完美地和任何服务器端技术结合。
AngularJS是为了克服HTML在构建应用上的不足而设计的。HTML是一门很好的为静态文本展示设计的声明式语言,但要构建WEB应用的话它就显得乏力了。所以我做了一些工作(你也可以觉得是小花招)来让浏览器做我想要的事。
AngularJS提供了过滤器来对输入输出数据格式化。下面开始给大家介绍Angularjs过滤器使用,一起看看吧
•在html文件中和在js文件中使用
$scope.form_time
=
$filter('date')($scope.time,
'yyyy-MM-dd
HH:mm:ss');
<p>{{time
|
date:
'yyyy-MM-dd
HH:mm:ss'}}</p>
•内部过滤器和自定义过滤器
.filter('my_data_format',[function(){
return
function(data,str,sss){
console.log('data:
',data,'
str:
',str,'
sss:
',arguments[2]);
}
}]);
//var1就是第一个参数data,
123是第二个参数str,
this是第三个参数
<p>{{var1
|
my_data_format
:
123
:
'this'}}</p>
//对传入的数据进行处理
.filter('my_data_format',[function(){
return
function(data,str){
var
arr=[];
angular.forEach(data,
function(one_list){
if(one_list.status
==
str){
arr.push(one_list);
}
});
return
arr;
}
}]);
//过滤器可以用在绑定的值中,也可以用在ng-if="(lists
|
my_data_format:
'2').length>0",
和ng-show等;类似的表达式中。作为判断语句
<p
ng-repeat
=
"list
in
lists">姓名:{{list.name}},人数{{(lists
|
my_data_format:
'2').length}}</p>

阅读全文

与angular事件过滤相关的资料

热点内容
edi评测费用 浏览:775
废水管不停响 浏览:827
土壤阳离子交换能力最强的离子是 浏览:708
树脂桶结构图 浏览:589
喜牌饮水机多少价格 浏览:77
净水机废水管口能抬高多少 浏览:729
用于废水分离工艺的主要包括用于过滤 浏览:818
小巨人空气净化器效果怎么样 浏览:459
安全除垢剂 浏览:11
养水草用什么纯水机 浏览:678
洛恩斯净水器滤芯怎么换 浏览:677
污水处理优秀员工事迹材料 浏览:293
饮水机活性炭怎么样 浏览:619
屠宰废水污泥含量是多少 浏览:682
健康天使空气净化器怎么样 浏览:927
景区污水处理后怎么办 浏览:198
清洗反渗透膜方案 浏览:860
洁星力除垢剂主要成分 浏览:721
高压锅烧水水垢 浏览:329
小红门污水处理厂人员 浏览:331