要创建一个调用encodeURIComponent的过滤器,以下是HTML-
<div ng-app = "app"> <a href = "/foo/{{ 'bar&baz' | encodeURIComponent }}">Demo</a> </div>
以下是我们的角度-
var app = angular.module('app', []); app.filter('encodeURIComponent', function() { return window.encodeURIComponent; });