gpt4 book ai didi

javascript - 如何在Angularjs中向当前url添加参数

转载 作者:太空宇宙 更新时间:2023-11-04 16:06:13 25 4
gpt4 key购买 nike

我用这个得到了我当前的网址

   $location.url() which it '/details

这次我想添加一些参数,例如

'/details/student' 

如何在点击时将“/students”添加到我当前的网址,请有人建议帮助。谢谢。

  <tabset>
<tab heading="student" ng-click = "changeRoutes('student')">
<h4>STUDENTS</h4>
<p>Best students..</p>
</tab>
<tab heading="teacher" ng-click = "changeRoutes('teacher')">
<h4>TEACHERS</h4>
<p>Best teachers..</p>
</tab>

最佳答案

您需要为其定义路由器,如下所示:-

$stateProvider
//considering route.state is your current state and you need to go on student
.state(route.state + '.student', {
url: '/student',
templateUrl: 'app/examples/student/student.tmpl.html',
controller: 'StudentController'
});

然后在您的详细信息 Controller 中,您需要像下面一样移动到学生

$scope.baseState.name = $state.current;
$state.go($scope.baseState.name + '.student');

通过这种方式,您将在加载所有选项卡时加载它们的模板。

关于javascript - 如何在Angularjs中向当前url添加参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41850621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com