Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在ui路由器状态下将参数传递到模式窗口_Javascript_Angularjs_Angular Ui Router - Fatal编程技术网

Javascript 如何在ui路由器状态下将参数传递到模式窗口

Javascript 如何在ui路由器状态下将参数传递到模式窗口,javascript,angularjs,angular-ui-router,Javascript,Angularjs,Angular Ui Router,我一直在开发一个Angular应用程序,但我被某些东西卡住了。我使用ng repeat遍历对象列表,并访问该变量\u id。父页面的标记如下:单击“我删除”按钮时,我希望将\u id传递给父页面(当前页面)控制器,以便将其传递给模式窗口的控制器 <tr ng-repeat="bucket in buckets"> <td>{{ bucket.name }}</td> <td>{{ bu

我一直在开发一个Angular应用程序,但我被某些东西卡住了。我使用ng repeat遍历对象列表,并访问该变量
\u id
。父页面的标记如下:单击“我删除”按钮时,我希望将
\u id
传递给父页面(当前页面)控制器,以便将其传递给模式窗口的控制器

        <tr ng-repeat="bucket in buckets">
            <td>{{ bucket.name }}</td>
            <td>{{ bucket._id }}</td>
            <td class="col-sm-1">

                <!-- View Bucket Page -->
                <a ui-sref="bucketPage({ bucket_id: bucket._id })" class = "btn btn-primary">View</a>

                <!-- Delete Bucket -->
                <!-- <a ui-sref="userProfile({ bucket_id: bucket._id })" ng-click="deleteBucketModalWindow('sm')" class="btn btn-danger">Delete</a> -->
                <a ng-click="deleteBucketModalWindow('sm')" href="#/" class="btn btn-danger">Delete</a>
            </td>
        </tr>
这是模态窗口的控制器

 angular.module('ResourceBucket')
.controller('deleteBucketModalCtrl', function($scope, $modalInstance, $auth, $http, $window, $rootScope, Bucket){

    // Delete the bucket
    $scope.deleteBucket = function(){
        // close the modal
        $modalInstance.close();

        console.log("Inside deleteModal - bucket_id: ", $scope.bucket_id);

        // bucket_id gets passed through the "resolve"
        Bucket.deleteBucket($scope.bucket_id) 
            .then(function(data){
                console.log("Just deleted a bucket!", data);
            })
            .catch(function(response){
                console.log("In catch of deleteBucketModalCtrl: ", response);
            });
        };

    $scope.cancel = function(){
        // Just close the modal, dont do anything else
        // After you close the modal, in .then() refresh the data
        $modalInstance.close();
    }
});
    <!-- Add Bucket Modal -->
<div controller="deleteBucketModalCtrl">
    <div class="modal-header"> 
    </div>

    <div class="modal-body">
        <ul>

            <!-- Bucket Modal -->
            <div class = "row">
                <!-- Heading -->
                <h2 class="text-center">Sure, you want to delete the bucket?</h2>

                <button class="btn btn-danger" ng-click="deleteBucket()">Delete</button>
          <button class="btn btn-warning" ng-click="cancel()">Cancel</button>
            </div>
        </ul>
    </div>

    <div class="modal-footer">
    </div>
</div>
这是模态窗口的标记

 angular.module('ResourceBucket')
.controller('deleteBucketModalCtrl', function($scope, $modalInstance, $auth, $http, $window, $rootScope, Bucket){

    // Delete the bucket
    $scope.deleteBucket = function(){
        // close the modal
        $modalInstance.close();

        console.log("Inside deleteModal - bucket_id: ", $scope.bucket_id);

        // bucket_id gets passed through the "resolve"
        Bucket.deleteBucket($scope.bucket_id) 
            .then(function(data){
                console.log("Just deleted a bucket!", data);
            })
            .catch(function(response){
                console.log("In catch of deleteBucketModalCtrl: ", response);
            });
        };

    $scope.cancel = function(){
        // Just close the modal, dont do anything else
        // After you close the modal, in .then() refresh the data
        $modalInstance.close();
    }
});
    <!-- Add Bucket Modal -->
<div controller="deleteBucketModalCtrl">
    <div class="modal-header"> 
    </div>

    <div class="modal-body">
        <ul>

            <!-- Bucket Modal -->
            <div class = "row">
                <!-- Heading -->
                <h2 class="text-center">Sure, you want to delete the bucket?</h2>

                <button class="btn btn-danger" ng-click="deleteBucket()">Delete</button>
          <button class="btn btn-warning" ng-click="cancel()">Cancel</button>
            </div>
        </ul>
    </div>

    <div class="modal-footer">
    </div>
</div>

    当然,要删除该存储桶吗? 删除 取消

谢谢大家!

对不起,事实上我知道我做错了什么。在标记中,可以使用ng click传递参数,如下所示:

<a ng-click="deleteBucketModalWindow('sm', bucket._id)" href="" class="btn btn-danger">Delete</a>