0

I have a routeprovider:

 $routeProvider.when("/editor/:tripName*", {
              controller: "tripEditorController",
              controllerAs: "vm",
              templateUrl: "/views/tripEditorView.html"
          });

and in html something like :

<td><a ng-href="#/editor/{{ trip.name  | escape}}" class="btn btn-sm btn-primary">Manage</a></td>

But when I click on the button, my url is getting converted to something strange

/App/trips#!/#%2Feditor%2FIndia%2520Trip

Appreciate any pointer to get this fixed.

Vipin
  • 31
  • 1
  • 6
  • Possible duplicate of [AngularJS: Insert HTML from a string](http://stackoverflow.com/questions/14761724/angularjs-insert-html-from-a-string) – Heretic Monkey Jun 30 '16 at 18:09
  • @Vipin Have you fixed the bug? I have faced it also and I don't know how to fix it – Sanya Sep 03 '16 at 06:52

3 Answers3

0

ng-href directive don't require hash in the value. try like below.

<td>
  <a ng-href="editor/{{ trip.name  | escape}}" 
      class="btn btn-sm btn-primary">Manage</a>
</td>

Refer below Pages:
Doc: https://docs.angularjs.org/api/ng/directive/ngHref
Example: https://plnkr.co/edit/?p=preview

Venkat.R
  • 7,420
  • 5
  • 42
  • 63
  • Thanks but it is a single-page application and removing the # doesn't help. I am landing to the main page and then want to move to other part of page using this ng-href – Vipin Jun 30 '16 at 20:17
  • you are using ng-href, please share the working sample – Venkat.R Jul 01 '16 at 02:45
0

As I can see the code you are trying to edit the trip details, rather than getting details from trip name get it by id, because name may have space , dash etc. and while redirecting URL will get change.

Prianca
  • 484
  • 2
  • 8
0

only add an ! sign after hash as some cases work like that

Ricardo
  • 19
  • 1
  • 6