$filter

2018-03-06 18:32:00
admin
原创
539
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.bootcss.com/angular.js/1.4.6/angular.min.js"></script> 
</head>
<body ng-app="myApp">
    <div ng-controller="MyController">
        <p>姓名为 {{ lastName | myfilter }}</p>
        <p>姓名为 {{ name}}</p>
    </div>
<script>
    var app = angular.module('myApp',[]);
    app.controller('MyController',['$scope','$filter',function($scope,$filter) {
        $scope.lastName = "abcd";
        $scope.name = $filter('myfilter')('abcd');
    }]);
    app.filter("myfilter",function(){
        return function(input){
            return input+"filter";
        }
    });
</script>
</body>
</html>
				
				
  • QQ讨论群
  • 关注微信
    • 欢迎咨询
    • 欢迎加入QQ群 16506021
  • 公众号:源宝网络