AngularJS $state.go 参数

前端之家收集整理的这篇文章主要介绍了AngularJS $state.go 参数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、方式1

$state.go传递参数
.state('index-result',{
     url: '/index-result',params: { 'airline': null,'category': null,'menuTypes': null },templateUrl: 'templates/index-result.html',controller: 'ProductCtrl',})

var params = { airline: 1,category: 2,menuTypes: "3" };
$state.go("index-result",params);

var airline = $stateParams.airline;
var category = $stateParams.category;
var menuTypes = $stateParams.menuTypes;
console.log(airline + "," + category + "," + menuTypes);

2、方式2

.state('fooddetail',{
     url: '/fooddetail/:foodId',templateUrl: 'templates/fooddetail.html',controller: 'ProductDetailCtrl',})

<li class="col-lg-3 col-md-3 col-sm-4 col-xs-12" ng-repeat="item in productList">
    <a href="#/fooddetail/1001" class="Box">
    <div class="Box-img"></a>
</li>

console.log($stateParams.foodId);

猜你在找的Angularjs相关文章