0

A quick question, how can I get the link to refer to post.id, this what I have not dosn't work. post.id has a existing value.

<a href={{post.id}}><h2 class="text-center">{{post[0].title}}</h2></a>
1

1 Answer 1

7

There is ngHref for this kind of use:

Examples:

<input ng-model="value" /><br />
<a id="link-1" href ng-click="value = 1">link 1</a> (link, don't reload)<br />
<a id="link-2" href="" ng-click="value = 2">link 2</a> (link, don't reload)<br />
<a id="link-3" ng-href="/{{'123'}}">link 3</a> (link, reload!)<br />
<a id="link-4" href="" name="xx" ng-click="value = 4">anchor</a> (link, don't reload)<br />
<a id="link-5" name="xxx" ng-click="value = 5">anchor</a> (no link)<br />
<a id="link-6" ng-href="{{value}}">link</a> (link, change location)

Source (Angular docs).

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

1 Comment

You're welcome, please consider accepting the answer.

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.