AngularJS Filter with encodeURIComponent Not Working in Link2019 Community Moderator ElectionHow can I invoke encodeURIComponent from angularJS template?How does data binding work in AngularJS?'this' vs $scope in AngularJS controllersHow do I access the $scope variable in browser's console using AngularJS?What are the nuances of scope prototypal / prototypical inheritance in AngularJS?What is the difference between '@' and '=' in directive scope in AngularJS?Working with $scope.$emit and $scope.$on“Thinking in AngularJS” if I have a jQuery background?How do I use $scope.$watch and $scope.$apply in AngularJS?AngularJS: Service vs provider vs factoryif else statement in AngularJS templates
How did Alan Turing break the enigma code using the hint given by the lady in the bar?
Rewrite the power sum in terms of convolution
Are all players supposed to be able to see each others' character sheets?
Coax or bifilar choke
Plausibility of Mushroom Buildings
Is "history" a male-biased word ("his+story")?
Is it "Vierergruppe" or "Viergruppe", or is there a distinction?
Sort with one element at the end
Examples of a statistic that is not independent of sample's distribution?
What is Earthy controling in the ISS cupola?
List elements digit difference sort
Looking for word that is not atheist or agnostic,
Linux Ubuntu 18.04 Full Backup
How strictly should I take "Candidates must be local"?
Signed and unsigned numbers
Database Backup for data and log files
How can I ensure my trip to the UK will not have to be cancelled because of Brexit?
Accepted offer letter, position changed
Do items de-spawn in Diablo?
Was Luke Skywalker the leader of the Rebel forces on Hoth?
In the quantum hamiltonian, why does kinetic energy turn into an operator while potential doesn't?
What Happens when Passenger Refuses to Fly Boeing 737 Max?
Motivation for Zeta Function of an Algebraic Variety
Single word request: Harming the benefactor
AngularJS Filter with encodeURIComponent Not Working in Link
2019 Community Moderator ElectionHow can I invoke encodeURIComponent from angularJS template?How does data binding work in AngularJS?'this' vs $scope in AngularJS controllersHow do I access the $scope variable in browser's console using AngularJS?What are the nuances of scope prototypal / prototypical inheritance in AngularJS?What is the difference between '@' and '=' in directive scope in AngularJS?Working with $scope.$emit and $scope.$on“Thinking in AngularJS” if I have a jQuery background?How do I use $scope.$watch and $scope.$apply in AngularJS?AngularJS: Service vs provider vs factoryif else statement in AngularJS templates
I am trying to encode a value passed in an URL using a filter that calls encodeURIComponent.
My original filter
angular.
module('machineorderDetail').
filter('encodeURIComponent', function ()
return window.encodeURIComponent;
).
was based on this post
How can I invoke encodeURIComponent from angularJS template?
When this didn't work I tried some other suggestions and injected $window, wrapped it in another function and changed href to ng-href. Both the original version and this new version return the same output.
angular.
module('machineorderDetail').
filter('encodeURIComponent', ['$window', function ($window)
return function (input)
return encodeURIComponent(input);
;
]).
If I do this I can see the encoded value as expected in the console out.
angular.
module('machineorderDetail').
filter('encodeURIComponent', ['$window', function ($window)
return function (input)
var retVal = encodeURIComponent(input);
console.log(retVal);
return retVal;
;
]).
console output

I can bind it like this the result is the encoded value.
<div>MachineOrderFile.DocumentName </div>
However when I put in in either an href or an ng-href the value is not encoded.
<a ng-href="#!/machineorders/fileupload/ encodeURIComponent/$ctrl.machineorder.MachineOrderHeader.ID">
The value "Japan/Singapore PO" should be Japan%2FSingapore%20PO but it is unchanged.
screenshot of url

Any help or suggestions would be greatly appreciated.
For MikeS showing encoded url when hovering in you jsfiddle
screenshot of jsfiddle
angularjs asp.net-mvc encodeuricomponent angularjs-ng-href
add a comment |
I am trying to encode a value passed in an URL using a filter that calls encodeURIComponent.
My original filter
angular.
module('machineorderDetail').
filter('encodeURIComponent', function ()
return window.encodeURIComponent;
).
was based on this post
How can I invoke encodeURIComponent from angularJS template?
When this didn't work I tried some other suggestions and injected $window, wrapped it in another function and changed href to ng-href. Both the original version and this new version return the same output.
angular.
module('machineorderDetail').
filter('encodeURIComponent', ['$window', function ($window)
return function (input)
return encodeURIComponent(input);
;
]).
If I do this I can see the encoded value as expected in the console out.
angular.
module('machineorderDetail').
filter('encodeURIComponent', ['$window', function ($window)
return function (input)
var retVal = encodeURIComponent(input);
console.log(retVal);
return retVal;
;
]).
console output

I can bind it like this the result is the encoded value.
<div>MachineOrderFile.DocumentName </div>
However when I put in in either an href or an ng-href the value is not encoded.
<a ng-href="#!/machineorders/fileupload/ encodeURIComponent/$ctrl.machineorder.MachineOrderHeader.ID">
The value "Japan/Singapore PO" should be Japan%2FSingapore%20PO but it is unchanged.
screenshot of url

Any help or suggestions would be greatly appreciated.
For MikeS showing encoded url when hovering in you jsfiddle
screenshot of jsfiddle
angularjs asp.net-mvc encodeuricomponent angularjs-ng-href
When you click on the link is it not encoded? When you hover over a link as in your screenshot the browser will decode the URL. For example if you hover over the link in this example jsfiddle.net/oe2mbrpy its decoded, but clicking it shows correctly in the address bar
– MikeS
Mar 6 at 15:31
Correct, when I click on the link it is not encoded. Also neither Chrome or FireFox is decoding the URL on hover. When I hover on the link in the jsfiddle it is encoded, for what it's worth. Added screenshot to my post to show hovering in your jsfiddle.
– user2448445
Mar 6 at 16:27
It looks to me as if you are using Angular and not AngularJS (an earlier version of Angular). If this is the case then filters arent available, I dont know Angular as much but its likley pipes you want to look at angular.io/guide/pipes
– MikeS
Mar 6 at 17:01
add a comment |
I am trying to encode a value passed in an URL using a filter that calls encodeURIComponent.
My original filter
angular.
module('machineorderDetail').
filter('encodeURIComponent', function ()
return window.encodeURIComponent;
).
was based on this post
How can I invoke encodeURIComponent from angularJS template?
When this didn't work I tried some other suggestions and injected $window, wrapped it in another function and changed href to ng-href. Both the original version and this new version return the same output.
angular.
module('machineorderDetail').
filter('encodeURIComponent', ['$window', function ($window)
return function (input)
return encodeURIComponent(input);
;
]).
If I do this I can see the encoded value as expected in the console out.
angular.
module('machineorderDetail').
filter('encodeURIComponent', ['$window', function ($window)
return function (input)
var retVal = encodeURIComponent(input);
console.log(retVal);
return retVal;
;
]).
console output

I can bind it like this the result is the encoded value.
<div>MachineOrderFile.DocumentName </div>
However when I put in in either an href or an ng-href the value is not encoded.
<a ng-href="#!/machineorders/fileupload/ encodeURIComponent/$ctrl.machineorder.MachineOrderHeader.ID">
The value "Japan/Singapore PO" should be Japan%2FSingapore%20PO but it is unchanged.
screenshot of url

Any help or suggestions would be greatly appreciated.
For MikeS showing encoded url when hovering in you jsfiddle
screenshot of jsfiddle
angularjs asp.net-mvc encodeuricomponent angularjs-ng-href
I am trying to encode a value passed in an URL using a filter that calls encodeURIComponent.
My original filter
angular.
module('machineorderDetail').
filter('encodeURIComponent', function ()
return window.encodeURIComponent;
).
was based on this post
How can I invoke encodeURIComponent from angularJS template?
When this didn't work I tried some other suggestions and injected $window, wrapped it in another function and changed href to ng-href. Both the original version and this new version return the same output.
angular.
module('machineorderDetail').
filter('encodeURIComponent', ['$window', function ($window)
return function (input)
return encodeURIComponent(input);
;
]).
If I do this I can see the encoded value as expected in the console out.
angular.
module('machineorderDetail').
filter('encodeURIComponent', ['$window', function ($window)
return function (input)
var retVal = encodeURIComponent(input);
console.log(retVal);
return retVal;
;
]).
console output

I can bind it like this the result is the encoded value.
<div>MachineOrderFile.DocumentName </div>
However when I put in in either an href or an ng-href the value is not encoded.
<a ng-href="#!/machineorders/fileupload/ encodeURIComponent/$ctrl.machineorder.MachineOrderHeader.ID">
The value "Japan/Singapore PO" should be Japan%2FSingapore%20PO but it is unchanged.
screenshot of url

Any help or suggestions would be greatly appreciated.
For MikeS showing encoded url when hovering in you jsfiddle
screenshot of jsfiddle
angularjs asp.net-mvc encodeuricomponent angularjs-ng-href
angularjs asp.net-mvc encodeuricomponent angularjs-ng-href
edited Mar 6 at 16:30
user2448445
asked Mar 6 at 15:15
user2448445user2448445
13
13
When you click on the link is it not encoded? When you hover over a link as in your screenshot the browser will decode the URL. For example if you hover over the link in this example jsfiddle.net/oe2mbrpy its decoded, but clicking it shows correctly in the address bar
– MikeS
Mar 6 at 15:31
Correct, when I click on the link it is not encoded. Also neither Chrome or FireFox is decoding the URL on hover. When I hover on the link in the jsfiddle it is encoded, for what it's worth. Added screenshot to my post to show hovering in your jsfiddle.
– user2448445
Mar 6 at 16:27
It looks to me as if you are using Angular and not AngularJS (an earlier version of Angular). If this is the case then filters arent available, I dont know Angular as much but its likley pipes you want to look at angular.io/guide/pipes
– MikeS
Mar 6 at 17:01
add a comment |
When you click on the link is it not encoded? When you hover over a link as in your screenshot the browser will decode the URL. For example if you hover over the link in this example jsfiddle.net/oe2mbrpy its decoded, but clicking it shows correctly in the address bar
– MikeS
Mar 6 at 15:31
Correct, when I click on the link it is not encoded. Also neither Chrome or FireFox is decoding the URL on hover. When I hover on the link in the jsfiddle it is encoded, for what it's worth. Added screenshot to my post to show hovering in your jsfiddle.
– user2448445
Mar 6 at 16:27
It looks to me as if you are using Angular and not AngularJS (an earlier version of Angular). If this is the case then filters arent available, I dont know Angular as much but its likley pipes you want to look at angular.io/guide/pipes
– MikeS
Mar 6 at 17:01
When you click on the link is it not encoded? When you hover over a link as in your screenshot the browser will decode the URL. For example if you hover over the link in this example jsfiddle.net/oe2mbrpy its decoded, but clicking it shows correctly in the address bar
– MikeS
Mar 6 at 15:31
When you click on the link is it not encoded? When you hover over a link as in your screenshot the browser will decode the URL. For example if you hover over the link in this example jsfiddle.net/oe2mbrpy its decoded, but clicking it shows correctly in the address bar
– MikeS
Mar 6 at 15:31
Correct, when I click on the link it is not encoded. Also neither Chrome or FireFox is decoding the URL on hover. When I hover on the link in the jsfiddle it is encoded, for what it's worth. Added screenshot to my post to show hovering in your jsfiddle.
– user2448445
Mar 6 at 16:27
Correct, when I click on the link it is not encoded. Also neither Chrome or FireFox is decoding the URL on hover. When I hover on the link in the jsfiddle it is encoded, for what it's worth. Added screenshot to my post to show hovering in your jsfiddle.
– user2448445
Mar 6 at 16:27
It looks to me as if you are using Angular and not AngularJS (an earlier version of Angular). If this is the case then filters arent available, I dont know Angular as much but its likley pipes you want to look at angular.io/guide/pipes
– MikeS
Mar 6 at 17:01
It looks to me as if you are using Angular and not AngularJS (an earlier version of Angular). If this is the case then filters arent available, I dont know Angular as much but its likley pipes you want to look at angular.io/guide/pipes
– MikeS
Mar 6 at 17:01
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55026393%2fangularjs-filter-with-encodeuricomponent-not-working-in-link%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55026393%2fangularjs-filter-with-encodeuricomponent-not-working-in-link%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
When you click on the link is it not encoded? When you hover over a link as in your screenshot the browser will decode the URL. For example if you hover over the link in this example jsfiddle.net/oe2mbrpy its decoded, but clicking it shows correctly in the address bar
– MikeS
Mar 6 at 15:31
Correct, when I click on the link it is not encoded. Also neither Chrome or FireFox is decoding the URL on hover. When I hover on the link in the jsfiddle it is encoded, for what it's worth. Added screenshot to my post to show hovering in your jsfiddle.
– user2448445
Mar 6 at 16:27
It looks to me as if you are using Angular and not AngularJS (an earlier version of Angular). If this is the case then filters arent available, I dont know Angular as much but its likley pipes you want to look at angular.io/guide/pipes
– MikeS
Mar 6 at 17:01