在父控制器中,添加以下内容:
$scope.isHome = function(){
return $state.is("home");
}
然后像这样更改模板:
<top-bar ng-if="!isHome()"></top-bar>
<ui-view class="reveal-animation"></ui-view>
<bottom-bar ng-if="!isHome()"></bottom-bar>
在这里查看这个 plunkr 以查看一些实时代码。
另一种方法是使用
$stateChangeSuccess
,像这样:
$scope.$on("$stateChangeSuccess", function(event, toState){
$scope.isHome = (toState.name == "home")
})
我还建议查看
$state.includes
、$state.current
和其他人。只需阅读文档here
一次教你所有的东西并不容易。你必须参考几个概念。
http://viralpatel.net/blogs/angularjs-routing-and-views-tutorial-with-example/
我希望这个链接能帮助你开始使用 Angularjs。