How to do a URL validation with Angularjs

Asked

Viewed 57 times

0

I am working on a project.. but I need to do a validation taking the current url.. Ex:

If(url('/questions/ask')){
    // Aqui vem minha lógica
}

How do I do this with Angularjs('I’m new at angular..') ?

Thank you.

  • 2

    What validation?

  • of the brother url..

  • 1

    What kind of validation Brother?

  • Do you want to check the address bar URL or validate a URL that came from an INPUT? Please explain this right.

  • taking the current url... I was very explicit in the question

1 answer

1

You can and should do this using Javascript.

Just use the window.location.href.

It will have return to the URL you are at the moment.

That way you can do:

if(window.location.href == 'www.google.com'){
    //Sua lógica aqui
}

For more information about window.Location, see here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.