如何在ng-repeat中使用ng-click显示离子弹出窗口



这是我的HTML代码。

    <div class='list' ng-repeat='worker in categories' >
    <br><a class="item item-thumbnail-left" ng-click="showConfirm(worker.$id)">
    <img src="img/tech_support.png">
    <p>{{worker.$id}}</p>
    <p>Address: {{worker.Address}}</p>
    <p><u>more..</u></p>
    </a>
    </div>

这是我的控制器.js

man.controller('categoryCtrl',function($scope,$firebaseArray,
                    $firebaseObject,$state,$stateParams,$ionicPopup,$window,$timeout){

        var category = $stateParams.categoryId;
        var categoryRef = Refroot.child('Workers').child(category);
        $scope.categories=$firebaseArray(categoryRef);

        $scope.showConfirm= function(id){
                var workerId = id;
                var workRef = Refroot.child('Workers');
                var lastRef = workRef.child(category).child(workerId);
                $scope.workerlist = $firebaseArray(lastRef);
                var confirmPopup = $ionicPopup.confirm({
                    title: 'Worker Profile',
        });
        confirmPopup.then(function(res) {
                if(res) {
                console.log('Sure!');
                } else {
                console.log('Not sure!');
                }
        });
        console.log(workerId + '' + category + '' + lastRef);
        }

});

希望你们能帮助我,这对我的论文有很大帮助:)

你应该使用如下$index

    <div class='list' ng-repeat='worker in categories track by $index'  >
            <br><a class="item item-thumbnail-left" ng-click="showConfirm($index)">
            <img src="img/tech_support.png">
            <p>{{$index}}</p>
            <p>Address: {{worker.Address}}</p>
            <p><u>more..</u></p>
            </a>
    </div>

相关内容

  • 没有找到相关文章

最新更新