demo.html:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>AngularJS</title> <script src="angular.min.js"></script> <!-- Introduce AngularJS framework--> </head> <body ng-app="App"> <div ng-controller="DemoController"> <h3>{{name|demo:"haha"}}</h3> <!-- use custom filter--> </div> <script> var App = angular.module('App',[]); App.filter('demo',function() { return function(input,param) { // The first parameter input is the data to be processed, and the second parameter param is the filter's own parameter console.log(input); return input + param; // return the processed data } }); App.controller("DemoController",['$scope',function($scope) { $scope.name = "小明"; }]); </script> </body> </html>