加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 如何在角度和离子中重定向到另一个页面

发布时间:2020-12-17 17:15:20 所属栏目:安全 来源:网络整理
导读:我在使用角度js的离子重定向方面存在问题.这是我的代码 app.js angular.module('test',['ionic','test.controllers',]).run(function($rootScope,$state,$ionicPlatform,$window) { $ionicPlatform.ready(function() { if (window.cordova window.cordova.pl
我在使用角度js的离子重定向方面存在问题.这是我的代码

app.js

angular.module('test',['ionic','test.controllers',])

.run(function($rootScope,$state,$ionicPlatform,$window) {
    $ionicPlatform.ready(function() {
        if (window.cordova && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        }
        if (window.StatusBar) {
            // org.apache.cordova.statusbar required
            StatusBar.styleDefault();
        }
    });
})

.config(function($stateProvider,$urlRouterProvider) {
    $stateProvider

        .state('opener',{
            cache: false,url: '/opener',templateUrl: 'templates/opener.html',controller: 'appController'
        })
        .state('app.main',{
            url: '/main',views: {
                'menuContent': {
                    templateUrl: 'templates/main.html',controller: 'mainController'
                }
            }
        })
        .state('app',{
            url: '/app',abstract: true,templateUrl: 'templates/menu.html',controller: 'menuController'
        })
    $urlRouterProvider.otherwise('/opener');
})


// controllers.js file 


angular.module('test.controllers',[])

.controller('appController',function($scope,$location) {
        $scope.gotoMain = function() {
            window.localStorage['UserSession'] = 'NOT_LOGIN';
            $location.path("/templates/main");
        }
    })
    .controller('menuController',function($scope) {
        $scope.myClass = "ion-navicon";
        $scope.toggleLeft = function() {
            if ($scope.myClass === "ion-navicon")
                $scope.myClass = "ion-arrow-left-c";
            else
                $scope.myClass = "ion-navicon";
        };
    })

// Main Screen Controller
.controller('mainController',$ionicLoading) {

})

在我使用$location.path(‘/ path’)的代码中;

但我也试过$state.go(‘/ path’);
请帮我解决这个问题.

解决方法

使用这个$state.go(‘app.main’);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读