title: Angularjs with typescript - Navigate to URL and to get parameter query string
body: <p>I have a login page, when credentials not correct, i need to return to the same page to get a environment variable (of query string):</p>
  
  <pre><code>if (login==false) {
  vm.$rootRouter.navigateByUrl('/login?fail=ko');
  }
  </code></pre>
  
  <p>When I call the URL "/login", i am going to another component view1ViewComp:</p>
  
  <pre><code>this.$routeConfig = [
  {
  path: '/login',
  name: 'View1',
  component: 'view1ViewComp'
  }
  </code></pre>
  
  <p>And this controller (View1ViewCtrl) must get the variable value  "?fail=ko" in the constructor method:</p>
  
  <pre><code>vm.fail = this.getParURL('fail');
  </code></pre>
  
  <p>But the value "vm.fail" is empty.</p>
  
  <pre><code>Function getParULR:
  
      getParURL(name) {
        let regexS = "[\\?&amp;]" + name + "=([^&amp;#]*)";
        let regex = new RegExp(regexS);
        let tmpURL = window.location.href;
        let results = regex.exec(tmpURL);
  
        if (results == null) {
          return "";
        }
        else {
          return results[1];
        }
      }
  </code></pre>
  
  <p>What could be the problem?</p>