angualr ui router 如何传递参数?如何获取参数,在线等,急


angualr ui router 如何传递参数?如何获取参数,在线等,急

ui-router angularjs JavaScript

真目可丽儿 9 years, 5 months ago

类似这样


 var myApp = angular.module("myApp", [ui.router]);
myApp.config(function ($stateProvider, $urlRouterProvider) {
     $urlRouterProvider.when("", "/PageTab");
     $stateProvider
        .state("PageTab", {
            url: "/PageTab",
            templateUrl: "PageTab.html"
        })
        .state("PageTab.Page1", {
            url:"/Page1",
            templateUrl: "Page-1.html"
        })
        .state("PageTab.Page2", {
            url:"/Page2",
            templateUrl: "Page-2.html"
        })
        .state("PageTab.Page3", {
            url:"/Page3",
            templateUrl: "Page3.html"
        });
});

杯具党路过 answered 9 years, 5 months ago

建议你去ui-router官网上查查 https://github.com/angular-ui/ui-router/wiki

下面是我在stack overflow上搜的答案
文档 https://github.com/angular-ui/ui-router/wiki/URL-Routing#stateparams-service
例子 http://plnkr.co/edit/8p55FoKIFHZFcvleFANe?p=preview

不清楚你那里能不能翻墙,我贴个图给你
图片描述

别这么看着我 answered 9 years, 5 months ago


 .state('tab.shop-detail', {
    url: '/shops/:shop_id',
    views: {
      'tab-shops': {
        templateUrl: 'templates/shop-detail.html',
        controller: 'ShopDetailCtrl'
      }
    }
  })

//shop controller
$window.location.href = '#/tab/shops/'+shop_id;    
//ShopDetailCtrl 
controller('ShopDetailCtrl',function($scope,$stateParams) {
    if ($stateParams.shop_id) {

    }

vck226 answered 9 years, 5 months ago

Your Answer