1

My Html code with Angular js:

<li data-ng-repeat="i in items | searchFor:searchString | limitTo:limit" >
                        <p><a href="{{i.link}}" class="search-link">{{i.title}}</a></p>
                        <p>{{i.description}}</p>
                        <p><a class="small" href="{{i.link}}">{{i.link}}</a></p>                
                    </li>

W3c Validation giving error like below :
Bad value {{i.link}} for attribute href on element a: Illegal character in path segment: { is not allowed.

Nageswar
  • 62
  • 7

2 Answers2

3

Use ng-href for this. Angular will transform it to the correct value.

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

Finally - using data-ng-href will solve the problem with validation problems. (Related SO question What is the difference between ng-app and data-ng-app?)

Community
  • 1
  • 1
Zdenek Hatak
  • 1,135
  • 14
  • 23
  • 1
    ng-href is also giving error, but i have used data-ng-href then it's working fine.thanks for suggestion – Nageswar Aug 11 '16 at 07:31
  • Yeah, you are right - this SO question is related http://stackoverflow.com/questions/16184428/what-is-the-difference-between-ng-app-and-data-ng-app – Zdenek Hatak Aug 11 '16 at 07:35
0

You should use ngHref. That is what AngularJS recommends. The W3C validation error will also get resolved. Also if you use href there will be issue of broken link.

Arun Ghosh
  • 7,634
  • 1
  • 26
  • 38