Ville
Ville

Reputation: 494

updating ng-view without updating url

I'm studing angularJS and I have situation where I have to load a new view by clicking button, but keep the url same. I have done same with jQuery like this: $(".container").fadeOut("slow").load('page.html').hide().fadeIn();

How is it possible? I dont want to change/route url, because other view is useless without visiting the other view/page first. Transitions are necessery.

I was thinking ng-include also. But is it possible to strap it to a specific controller for each included template like it is via router(like below)? Or should i do some custom directive?

        .when('/page', {
        controller: Controller,
        templateUrl: 'page.html'
    })

Thanks!

Upvotes: 4

Views: 611

Answers (1)

rgaskill
rgaskill

Reputation: 2067

Your only real options if you don't want to change the path are to use ng-include or a custom directive. The easiest thing to do would be use ng-include. You can just add a ng-controller to the root element of you included HTML for your controller mapping.

Ng-view only works with routes so a path change would be required to use ng-view.

Upvotes: 1

Related Questions