javascript - Routing without template/controller combo? -


i map each route function, rather controller/template.

i have 1 page, items change on page scope variables. i'd prefer avoiding controller , template reload, i'd rather swap variables.

is possible $routeprovider?


apologies being unclear, here example:

the app 1 template , 1 controller threadctrl

app.controller("threadctrl", function($scope) {   $scope.topic = "all";   $scope.sorting = "best";   $scope.articles = get_articles_for_topic(...);   $scope.$watch "topic", ...   $scope.$watch "sorting", ... }); 

template example:

<div ng-controller="topicctrl">     {{ topic }} - {{ sorting }}     <div ng-repeat="article in articles">         ...     </div> </div> 

there 1 template , 1 controller. i'd make use of routing without re-rendering controller , changing scope variables.

i understand if example should re-render template + controller default, want know if can.


an alternative question "can map route function has access $rootscope?"


thanks :)

maybe make use of parameters in route?

you define route this:

when('/thread/:topic', {       templateurl: 'templates/thread.html',       controller: 'threadctrl' }); 

and in controller make use of parameter:

app.controller("threadctrl", function($scope) {   $scope.topic = $routeparams.topic;   $scope.sorting = "best";   $scope.articles = get_articles_for_topic(...);   $scope.$watch "topic", ...   $scope.$watch "sorting", ... }); 

this how it, i'm curious whether there better solution this.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -