Angularjs list and detail view

后端 未结 1 1138
别那么骄傲
别那么骄傲 2021-02-10 22:32

this is my basic scenario. For a list of items (summary view) i want to show details view of item that got clicked on the same page.

I took this jsfiddle example and tra

相关标签:
1条回答
  • 2021-02-10 22:48

    One way of transforming the example (provided that you want to use ngSwitch) would be:

    <ul ng-controller="ListController">
        <li ng-repeat="item in items" ng-controller="ItemController">
            <div ng-click="open(item)">{{item.content}}</div>        
        </li>
        <hr>
        <ng-switch on="anyItemOpen()">
         <div ng-switch-when="true">
             <div ng-controller="ItemController">
                 {{opened.name}}: overlay: tweet, share, pin
             </div>  
             <a ng-click="close()">close</a>         
         </div>
        </ng-switch>   
    </ul>
    

    And here is the working jsFiddle: http://jsfiddle.net/pkozlowski_opensource/sJdzt/4/

    Your jsFiddle didn't work since you were trying to reference item created in the ngRepeat scope (and thus not available outside of the ngRepeat).

    0 讨论(0)
提交回复
热议问题