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.

2
  • Possible duplicate of AngularJS: Insert HTML from a string Commented Jun 30, 2016 at 18:09
  • @Vipin Have you fixed the bug? I have faced it also and I don't know how to fix it Commented Sep 3, 2016 at 6:52

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

2 Comments

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
you are using ng-href, please share the working sample
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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.