Skip to content

ng-show does not work with ui-view in v0.2.8 #867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gabrielmaldi opened this issue Feb 7, 2014 · 3 comments
Closed

ng-show does not work with ui-view in v0.2.8 #867

gabrielmaldi opened this issue Feb 7, 2014 · 3 comments

Comments

@gabrielmaldi
Copy link

It seems that we can't use ng-show on a ui-view in v0.2.8.

Given the following:

<div ng-app="myApp">
    ui-view does not play well with ng-show:

    <ui-view name="main" ng-show="showView"></ui-view>
</div>
angular
    .module("myApp", ["ui.router"])
    .config(function ($stateProvider, $urlRouterProvider) {
        $urlRouterProvider.otherwise("/state1");

        $stateProvider
            .state("state1", {
                url: "",
                views: {
                    "main": {
                        template: "This won't be visible when using ng-show, even though showView = {{ showView }}",
                        controller: function ($scope) {
                            $scope.showView = true;
                        }
                    }
                }
            });
    });

The class ng-hide is always applied to the ui-view, and it is not an issue with the value of showView, because this is what the ui-view ends up containing:

<span class="ng-scope ng-binding">This won't be visible when using ng-show, even though showView = true</span>

Fiddle: http://jsfiddle.net/VhNLX

Thanks!

@timkindberg
Copy link
Contributor

This may also be a dupe of #834. Please see and close if so.

@gabrielmaldi
Copy link
Author

#834 states that the problem is the combination of ng-init with ng-show/ng-hide:

This problem only appears when ng-init is used to set pageIsLoading = true and when the ng-hide appears directly on the ui-view tag.

  • Removing the ng-init resolves the problem, but also removes my ability to show loading spinners.

However, ng-init is not related, as this issue (which doesn't make use of it) demonstrates.

Perhaps @damienklinnert can look at this and reduce #834 to its simplest form (i.e. without using ng-init). That way we can close this issue and keep his, because he did a great job investigating what is happening.

@gabrielmaldi
Copy link
Author

This is fixed in #858

http://jsfiddle.net/VhNLX/9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants