title: Use href or sref according to the location path in angularjs
body: <p>I have a modularized AngularJS1.5 application, what I mean by modularized is that it used to be a monolithic frontend and I have split it in different applications each one of them running in Kubernetes.</p>
  
  <p>Since now it has been split, all of the applications share the common and core modules that I've packed into an NPM and it's being added to each of them in the Jenkins pipeline.</p>
  
  <p>All the applications share the same UX style frontend including it's navigation pane. Now to change between modules, the user just goes to the navigation pane and clicks the desired link.</p>
  
  <p>What I want to do is if the user is already let's say in the foo module and wants to navigate to FOO1 which is still inside the parent FOO module perform and sref navigation, but if it's in the FOO module and wants to go to BAR module perform an href.</p>
  
  <p>To better explain this, this is my current scenario:</p>
  
  <p>www.domain.com/foo</p>
  
  <p>Navigation Bar</p>
  
  <pre><code>|-&gt;FOO
    |--&gt;FOO1
    |--&gt;FOO2
    |--&gt;FOO3
  |-&gt;BAR
    |--&gt;BAR1
    |--&gt;BAR2
    |--&gt;BAR3
  </code></pre>
  
  <p>This is the code that I have in my navigation.provider.js</p>
  
  <pre><code>(function (angular) {
      'use strict';
  
      angular.module('xxxx.core.layout')
          .provider('xxxx.core.layout.NavigationProvider', NavigationProvider);
  
      NavigationProvider.$inject = [
          'xxxx.core.states.StatesConstant',
          'xxxx.core.auth.PermissionConstant',
          '$windowProvider',
          '$location',
          'xxxx.core.auth.PermissionTypeConstant',
          'xxxx.core.features.FeaturesConstant'
      ];
  
      function NavigationProvider(StatesConstant, PermissionConstant, $windowProvider, $location, PermissionTypeConstant, FeaturesConstant) {
          this.$get = Navigation;
  
          function Navigation() {
              var $window = $windowProvider.$get();
              return [
  text: 'FOO',
                      permission: [
                          PermissionConstant.XXXX,
                          PermissionConstant.XXXX_EDIT
                      ].toString(),
                      permissionType: PermissionTypeConstant.AT_LEAST_ONE,
                      children: [
                          {
                              text: 'User Management',
                              //sref: StatesConstant.USER_MANAGEMENT_LIST,
                              href: $window.location.protocol + '//' + $window.location.hostname + '/foo/um/list',
                              permission: PermissionConstant.XXXX
                          },
                          {
                              text: 'Active Features',
                              //sref: StatesConstant.TOGGLE_ADMINISTRATOR,
                              href: $window.location.protocol + '//' + $window.location.hostname + '/foo/toggle',
                              permission: PermissionConstant.XXXX
                          },
                          {
                              text: 'Customer List',
                              //sref: StatesConstant.XXXX_LIST,
                              href: $window.location.protocol + '//' + $window.location.hostname + '/foo/customer-list',
                              permission: PermissionConstant.XXXX_EDIT
                          }
                      ]
  </code></pre>
  
  <p>What I would like to implement,it is something like this:</p>
  
  <pre><code>let $location = $location.path();
  if($location = "/foo"){
  sref: StatesConstant.USER_MANAGEMENT_LIST,
  }else{
  href: $window.location.protocol + '//' + $window.location.hostname + '/foo/um/list',
  }
  </code></pre>
  
  <p>Any help would be greatly appreciated it.</p>
  
  <p>Cheers! </p>