Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

using ng-view inside another directive breaks refresh and back button #6812

Closed
@DinisCruz

Description

@DinisCruz

I hit an interesting problem yesterday with AngularJS views. They (the views) where working when clicking on a link, but not working when accessed directly, or when the back button was used

After quite a bit of debugging, I was able to track the problem to the fact that if I placed the ng-view directive inside another directive, the refresh and back button would break (although it would work ok for links and direct browser url manipulation).

Here is a blog post I just published with more details/screenshots about this issue: http://blog.diniscruz.com/2014/03/problem-with-angularjs-ng-view-it.html.

For reference here is the C# UnitTest that I wrote to replicate the issue:

    [Test]
    public void Page_Tbot_View_Bug()
    {                             
        var urlTemplate  = "{0}/tbot_v2/{1}";
        var expectedHtml = "This is a test";

        Action<string,bool> runTest = 
                (pageUrl, hasExpectedHtml) =>
                    {
                        var url         = urlTemplate.format(TargetServer, pageUrl);                            
                        ie.open(url);                                                        
                        "Current Url: {0}".info(ie.url());
                        "Current HTML {0}".info(ie.html()); 
                        Assert.AreEqual(hasExpectedHtml, html().contains(expectedHtml));                            
                    };


        runTest("default.htm#test" , false);        // default html has the ng-view inside a directive       
        runTest("users.htm#test"   , true);         // default html has the ng-view on this page            
    }        

Note: I looked at the other route and ng-view issues (like #2100 and #3825) but they don't seem to cover this scenario

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions