将params发送到url

时间:2018-04-02 21:22:02

标签: javascript angularjs ngroute

我正在使用ng-routes建立一个应用程序。我正在做的是从列表中的api获取信息,我需要在URL中发送一个值,因为下一页 - 该id的详细信息页面将捕获该值。

接下来,我的部分代码。首先,我收到了信息

function getData(){
    $http.get('/api/info')
    .then(function(response){
        $scope.fill = response.data;
        //console.log($scope.fill);
    });
}

在我的html视图中:

<tbody>
<tr ng-repeat="a in fill">
    <th>{{a.Id}}</th>
    <th>{{a.Name}}</th>
    <th>{{a.ContactStatus}}</th>
    <th>{{a.UserAsigned}}</th>
    <th><a ng-click="obtainId(a)">See more</a></th>
</tr>
</tbody>

然后,这是代码的一部分,我点击了

$scope.obtainId = function(a){
    $scope.sendId = a.Id;
    console.log($scope.sendId);
}

当我想将ID发送到详细信息页面时,我的问题就来了。我找到了下一个使用ng-routes发送到另一个页面的代码:

$scope.goToDetail = function(hash){
        $location.path(hash);
    }

关于html视图:

<button class="btn btn-danger" ng-click="goHome('/detail')"></button>

我已经测试了最后一个代码,它可以工作;它打开详细页面。现在,如何使用$location.path代码将获取的ID(使用onclick操作)在url上发送到详细信息页面?

我正在使用Javascript和AngularJs。

希望你能帮助我。

0 个答案:

没有答案
相关问题