angularjs - ng-repeat to create the hyperlink -


i have issue create list of hyperlink using ng-repeat. have user.spaces has array of objects like

user.spaces [ {device_name: 'phone1',  id : '11111' }, {device_name: 'phone2',  id='22222' ]  , want create list of device_name's hyper link below list of devices :          phone1         phone2 

and here code in .html file

<div ng-if="usercontroller.inedit" class="form-group">   <label class="col-sm-4">{{'user.workspace_user' | translate}}:</label>   <div class="col-sm-8">     <tr ng-repeat="space in user.spaces track $index">       <td><a href ng-click="gotospace(space)" id="linkspaces_{{$index}}" >{{space.device_name}}</a></td>     </tr>   </div> </div> 

didn't result want list of device's hyper links. suggestions need change in .html file make works in advance, kim

using angular markup {{hash}} in href attribute make link go wrong url if user clicks before angular has chance replace {{hash}} markup value. until angular replaces markup link broken , return 404 error. nghref directive solves problem.

also = operator missing in code

<td><a id="linkspaces_{{$index}}" href>{{space.device_name}}</a></td> 

change to

<td><a id="linkspaces_{{$index}}" ng-href="reference">{{space.device_name}}</a></td> 

the wrong way write it:

<a href="http://www.gravatar.com/avatar/{{hash}}">link1</a> 

the correct way write it:

<a ng-href="http://www.gravatar.com/avatar/{{hash}}">link1</a> 

see https://docs.angularjs.org/api/ng/directive/nghref better explanation how use it.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -