Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了angular1.x ui-route传参的三种写法大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
.state('classrooms',{
    url: '/classrooms/:id'
})
.state('classrooms',{
    url: '/classrooms/{iD}'
})
.state('activities',{
    url: '/activities',params: {
        id: { value: 42}
    }
})

localhost:3000/#/classrooms/3

function ClassroomController($stateParams){
    var classroomID = $stateParams.id;
}



  
  

一: 如何传递单个参数

首先,要在目标页面定义接受的参数:

传参,

@H_489_69@ui-sref:

$state.Go:

接收参数,

在目标页面的controller里注入$stateParams,然后 "$stateParams.参数名" 获取

@H_450_95@
二:传递多个参数其实也很简单可以在上面的单个后面直接拼
1:目标页面定义需要传的传输个数
.state("default.certquery",{
    url: "/certquery":rgb(102,controller"certQueryCtrl"params:{"LoginAccount":null"CertCode""CredentialsID"},//这个是重点其他可以不用看,具体路由对应自己项目
    template"<div ui-view></div>"
  
})
2:controll里面接受( 注入$stateParams,然后 "$stateParams.参数名
$state.go("default.certquery.certDetialQuery",{LoginAccount:$scope.entity.LoginAccount,CertCode:$scope.CertCode,122)">CredentialsID:$scope.CredentialsID});
我这里是用页面绑定的值作为参数传过去,大家可以传固定的,具体业务具体对待

三:传递对象
@H_262_222@

2)

 
   
$stateProvider .state('app.example1', { url: '/example' views'menuContent' templateUrl'templates/example.html' controller'ExampleCtrl'}})'app.example2''/example2/:object''templates/example2.html''Example2Ctrl'})controller'ExampleCtrl' function($state $scope @H_118_301@Userservice)goExample2 =obj $statego"app.example2"{object JSONStringify)});'Example2Ctrl' $stateParams consolelogJSONparse.params));})

大佬总结

以上是大佬教程为你收集整理的angular1.x ui-route传参的三种写法全部内容,希望文章能够帮你解决angular1.x ui-route传参的三种写法所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
猜你在找的Angularjs相关文章