I want to store the current URL in a hidden field on a form in a lightning component.

The input field on the component:

<ui:inputText aura:id="articleURL"value="{!c.getURL}"/>

Client-siide controller:

getURL : function(cmp, event){
                var articleURL = window.location.pathname;

I recieve an error that says the value: replace is not allowed in this context. Any ideas how I should be handling this?


Aura/lightning is intended to create single page applications. I am not sure how far you could go by storing URL, having said that I found a way to do this

Note: I tested this in my browser, not on SF1 app.


<aura:component >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <ui:inputText aura:id="articleURL"/>


        doInit: function(cmp) {
        cmp.find("articleURL").set("v.value", window.location.pathname);


enter image description here

  • Rao, you are the best. – Allen Mann Nov 5 '15 at 18:12
  • lol @AllenMann thanks for the compliment. I am hunting around to see how people are using lightning and answering mostly lightning based questions hence i get to play around a bit more. I am sure you will be way better than me in no time :) – Rao Nov 5 '15 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.