Reputation: 5535
I want to use ng-hide in the index page if the url in some nested views. in my index.html, I want something like:
<top-bar ng-if="!home"></top-bar>
<ui-view class="reveal-animation"></ui-view>
<bottom-bar ng-if="!home"></bottom-bar>
I want that when I enter to "home" view the bars will disappeared. as I saw here in same questions - the answer was to use $location in the controller, but where is the controller of the index page?
thanks
Upvotes: 0
Views: 5463
Reputation: 675
In a parent controller, add the following:
$scope.isHome = function(){
return $state.is("home");
}
Then change your template like this:
<top-bar ng-if="!isHome()"></top-bar>
<ui-view class="reveal-animation"></ui-view>
<bottom-bar ng-if="!isHome()"></bottom-bar>
Check this plunkr here to see some live code.
Another method would be using $stateChangeSuccess
, something like this:
$scope.$on("$stateChangeSuccess", function(event, toState){
$scope.isHome = (toState.name == "home")
})
I also recommend checking out $state.includes
, $state.current
and others. Just get through the documentation here
Upvotes: 3
Reputation: 55443
It is not easy to teach you everything in one go. You have to refer to few concept.
http://viralpatel.net/blogs/angularjs-routing-and-views-tutorial-with-example/
I hope this link will help you to getting started with Angularjs.
Upvotes: -1