Dependant ng-repeat in AngularJS -


i have following data structure coming rest:

scope.taglist =

[ { name: "mylist", tags: ["tag1", "tag2", "tag3", ...]}, { name: "mylist2", tags: ["tag2.1", "tag2.2", "tag2.3", ...]} ]

in order present names of objects have following html:

<div> <select ng-model="tagnameselection"> <option ng-repeat="tagobj in taglist" value="{{tagobj}}">{{tagobj.name}}</option> </select> </div>  <div class="tagdetails"> <!-- present list of tags tagnameselection --> </div> 

now little bit of loss on how present tags list of individual object. able present array in raw format (by sticking {{tagnameselection}} inside tagdetails div) when try iterate through ng-repeat angular gives error message.

oddly enough when hard-code 1 of tag lists scope in controller ng-repeat works flawlessly.

maybe interesting this:

html

<div ng-controller="fesscntrl">     <div>         <select ng-model="tagnameselection"                      ng-options="tagobj tagobj.name tagobj in taglist"                        ng-change="change(tagnameselection)"></select>     </div>      <pre>{{tagnameselection.tags|json}}</pre>      <div class="tagdetails">          <ul ng-repeat="tag in tagnameselection.tags">             <li>{{tag}}</li>         </ul>         </div> </div> 

controller

var fessmodule = angular.module('mymodule', []);  fessmodule.controller('fesscntrl', function ($scope) {        $scope.change = function (value) {     };      $scope.taglist = [{         name: "mylist",         tags: ["tag1", "tag2", "tag3"]     }, {         name: "mylist2",         tags: ["tag2.1", "tag2.2", "tag2.3"]     }]  });  fessmodule.$inject = ['$scope']; 

see fiddle


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -