动态路由角度js [英] Dynamic routing angular js

查看:49
本文介绍了动态路由角度js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面有一些文件和文件夹。我正在寻找的是选择任何文件/文件夹,其细节在新的引导程序选项卡中打开。在选择任何文件时,我在我的家庭控制器中的函数(changeType)中传递文件类型并在Config中捕获它



我尝试过:



----家庭控制器----

My Page have some files and folders.What i am looking is on selecting any file/folder, its detail get open in new bootstrap tab. On selecting any file i am passing file type in a function (changeType ) in my home controller and catching it in Config

What I have tried:

---- Home Controller ----

    myApp.controller("HomeController", ['$window', '$rootScope', '$scope', '$state', '$http', , function (.....) {
   $scope.changeType = function (type) {

 if (type == 'Folder') {
                $state.go('Folder');
            }
            else if (viewName == 'File') {
                $state.go('File'); 
            }
}}





----索引-----



---- Index -----

  <div id="divViews"> 
         <div ui-view="mainModule1"></div>
  <div ui-view="mainModule2"></div>

</div>



----路线配置----


---- Route Config ----

myApp.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
 $stateProvider.state('File', {
     url: '/File',
     views: {
         'mainModule1': {
             url: '',
             templateUrl: '/Views/HtmlDashBoard/File.html',
             controller: 'FileCtrl'
         }
     }      .state('Folder', {
     url: '/Folder',
     views: {
         'mainModule2': {
             url: '',
             templateUrl: '/Views/HtmlDashBoard/Folder.html',
             controller: 'FolderCtrl'
         }
     }



有没有办法将视图名称从家庭控制器传递到配置文件,因为我正在动态制作ui-views?


Is there any way to pass views name from home controller to config file since i am making ui-views dynamically ?

推荐答案

window ','
window', '


rootScope','
rootScope', '


scope','


这篇关于动态路由角度js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆