javascript - Need to pass $scope with variables to another page in angular? -


i have routes:

$routeprovider             .when('/', {                 templateurl: 'views/main.html',                 controller: 'mainctrl',                 controlleras: 'main'             })             .when('/next', {               templateurl: 'views/next.html',               controller: 'mainctrl',               controlleras: 'main'             })             .otherwise({                 redirectto: '/'             }); 

when i'm in main page. clicking next button , see 'views/next.html'. i'm not have $scope. how can scope?

new route renders new template , bind new scope template. can't use same scope both routes. however, there @ least 2 workarounds.

1). $rootscope. $rootscope available in views can store data in , able access in template.

2). service. use shared service in both controllers. optimal solution cases.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -