AngularJS具有相同回调ng-click的多个元素

时间:2014-10-16 15:18:39

标签: angularjs twitter-bootstrap angularjs-ng-click

我有多个元素,显示带有“相应标签”的图标。点击任何图标后,我想显示下一步。我可以简单地将ng-click事件处理程序附加到DOM元素的EACH以触发函数。我想找一个“清洁”的方式,我可以有一个“ng-click”,适用于每个元素(总共8个)。我是angularJS的新手,并没有找到替代方案。谢谢!

<ul class="list-inline row">
                <li class="col-sm-3">
                    <div class="col-sm-6" ng-click="displayStep2"><span class="glyphicon glyphicon-cutlery"></span>
                        <p>Cutlery &#38; Service</p>
                    </div>
                    <div class="col-sm-6"><span class="glyphicon glyphicon-off"></span>
                        <p>AV Equipment</p>
                    </div>
                </li>
                <li class="col-sm-3">
                    <div class="col-sm-6"><span class="glyphicon glyphicon-wrench"></span>
                        <p>Furniture &#38; Fixtures</p>
                    </div>
                    <div class="col-sm-6"><span class="glyphicon glyphicon-pencil"></span>
                        <p>Supplies</p>
                    </div>
                </li>
                <li class="col-sm-3">
                    <div class="col-sm-6"><span class="glyphicon glyphicon-road"></span>
                        <p>Transportation</p>
                    </div>
                    <div class="col-sm-6"><span class="glyphicon glyphicon-stats"></span>
                        <p>Set Up &#38; Clean Up</p>
                    </div>
                </li>
                <li class="col-sm-3">
                    <div class="col-sm-6"><span class="glyphicon glyphicon-envelope"></span>
                        <p>Shipment Tracking</p>
                    </div>
                    <div class="col-sm-6"><span class="glyphicon glyphicon-sort"></span>
                        <p>Temperature</p>
                    </div>
                </li>
            </ul>

<script>
    $scope.displayStep2 = function(){
        window.location.href = "/requestPortal/meeting/2/request/create";
    }; 
</scirpt>

0 个答案:

没有答案