2016-12-14 25 views
0

I've placed a below link in my code角度JS <a href> route back to LogIn

<a href="/#/list/' + data._id + '" class="btn btnprimary1" > LIST </a> 

It should routed to below point

.state('index.list', { 
      url: '/list/:id', 
      templateUrl: '/list.html', 
      data: { pageTitle: 'listing', pageFilter: 'off' }, 
      controller: 'listController', 
      }); 

Instead of that it routed to the main page /# and from that it checks login and rerouted to my current page

Is it a correct way to place href in angular code to route to a state with specific Id.

答えて

2

You should use ngHref

<a ng-href="/#/list/{{data._id}}"></a> 

または望ましいui-sref

<a ui-sref="index.list({id: data._id})"></a> 
+0

男うっ...おかげ –

+0

それは働いていたが、あなたはそれが起こった理由私はよりよく理解提供することができます。.. –

+1

は、解析し、コンパイルします。それは二重{{..}}がありません(そして、それは有効なjs式でもなく、引用符を見てください)。 ng-hrefとui-srefはディレクティブなので異なる。 – hansmaad

1

あなたは休閑のアプローチを使用する必要があります

<a ng-href="/#/list/{{data._id}}">LIST</a> 
1

あなたは角度のhrefタグの代わりに、NG-HREFディレクティブを使用する必要があります。 href属性のあなたの値は角式ではありません@AbhishekParikh

<a ng-href="http://127.0.0.1/projectFolder/#/list/{{data._id}}" class="btn btnprimary1"> LIST </a>