Filter to encode URL

Description

The following code shows how to use Filter to encode URL.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
var app = angular.module('app', []);
app.filter('encodeURIComponent', function() {
    return window.encodeURIComponent;<!--  www . jav  a  2 s . c o m-->
});
</script>
</head>
<body>
  <div ng-app="app"><a href="/foo/{{ 'bar&baz' | encodeURIComponent }}">Test</a>
  </div>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities