Angular.js: ng-show element when $state.current.name is a certain value

前端 未结 3 656
梦如初夏
梦如初夏 2020-12-28 16:50

I am looking to show a block of HTML only when $state.current.name equals about.list. So far I have the following code but it doesn\'t seem to be t

3条回答
  •  滥情空心
    2020-12-28 17:47

    The view (html) doesn't know about the variable $state. It only knows the $scope that is associated with the view.

    You can expose the $state variable on the $scope inside the controller that is associated with this view (you might have to inject $state into your controller as well):

    $scope.uiRouterState = $state;
    

    Then change the expression in your markup slightly:

提交回复
热议问题