How to ng-hide and ng-show views using angular ui router?

后端 未结 4 1145
有刺的猬
有刺的猬 2020-12-08 00:30

Imagine an application has a List page, such as a table showing a list of users. There is a button on each row of the table called \"Edit\", and when this is clicked, a righ

4条回答
  •  时光说笑
    2020-12-08 01:04

    In any way you solve this problem, just make sure that in your .run section on the angular app you declare something like this:

    angular.module('yourApp', ['ui.router'])
    
        .run(
            ['$rootScope', '$state', '$stateParams',
                function ($rootScope, $state, $stateParams){                    
                    $rootScope.$state = $state;
                    $rootScope.$stateParams = $stateParams;
                }
                ]
        )
    

    Otherwise neither $state, nor $stateParams will be accesible from the internal templates. Figured it out reading the ui-router docs and checking the example app's code, just after banging my head against the keyboard because this wasn't working.

提交回复
热议问题