Exposing the current state name with ui router

前端 未结 6 1525
清歌不尽
清歌不尽 2020-12-14 05:28

I\'m trying to implement a language switcher where if a user clicks on \"de\" from any given page on an \"en\" side - it takes them to that page of the \"de\" side. If I con

6条回答
  •  伪装坚强ぢ
    2020-12-14 06:04

    I wrapped around $state around $timeout and it worked for me.

    For example,

    (function() {
      'use strict';
    
      angular
        .module('app')
        .controller('BodyController', BodyController);
    
      BodyController.$inject = ['$state', '$timeout'];
    
      /* @ngInject */
      function BodyController($state, $timeout) {
        $timeout(function(){
          console.log($state.current);
        });
    
      }
    })();
    

提交回复
热议问题