2

The code:

<a ng-repeat="..." href="{{...}}"></a>

I am using a plugin that requires the href attribute, so data-ng-href can't be used :(

Is there an alternative to keeping an AngularJS expression inside a href attribute, and have it validate under the W3C HTML5 validator? Thanks in advance, will mark answer as correct :)

3
  • 1
    Unless it's an absolute requirement, I wouldn't be too concerned about the standards validity of Angular templates. Strictly speaking, they aren't actually HTML5, but Angular's extension of its functionality. As far as I'm aware Angular is not designed to allow this sort of conformation. Commented Oct 2, 2014 at 10:47
  • Thanks for the insight. If you want, feel free to add your comment as an actual answer and I'll mark it as correct Commented Oct 2, 2014 at 10:51
  • No worries, I've posted the answer. Commented Oct 2, 2014 at 10:52

2 Answers 2

1

Unless it's an absolute requirement, I wouldn't be too concerned about the standards validity of Angular templates. Strictly speaking, they aren't actually HTML5, but Angular's extension of its functionality. As far as I'm aware Angular is not designed to allow this sort of conformation. I think you'd be best just to leave validation behind.

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

Comments

1

Another opinion here, using data-ng-href will still produce an href once the template has been initialized, so perhaps your plugin can run once the template is ready? Here is the relevant code right from the angular docs:

<a id="link-3" ng-href="/{{'123'}}">link 3</a> (link, reload!)<br />

becomes

<a id="link-3" ng-href="/123" href="/123">link 3</a>

on the page.

ref - https://docs.angularjs.org/api/ng/directive/ngHref

I personally really like the fact that one can use angular and still have valid html5-

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.