title: How to get string subpath in AngularJS
body: <p>I have some data loaded from db and appended to html like below:</p>
  
  <pre><code>&lt;td&gt;
    &lt;p class="namepath" ng-bind-html="getNamePath(l)"&gt;&lt;/p&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p>My controller:</p>
  
  <pre><code>$scope.getNamePath = function (l) {
      let namepath = l.currpath;
      let t = namepath.split('/').map(function (text, i) {
          return '&lt;span ng-click="changeNamePath(' + i + ',' + namepath + ')"' + i + '&gt;' + text + '&lt;/span&gt;';
      }).join('/');
      return t;
  };
  </code></pre>
  
  <p>My l.currpath has some data like this:</p>
  
  <p><code>l.currpath = a/b/c/d</code>...</p>
  
  <p>When you click on c I want to return <code>a/b/c</code>, click on b I want to return <code>a/b</code>...</p>
  
  <p>How can I do this?</p>